Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG Export does not match sketch #835

Open
matiasw opened this issue Apr 21, 2024 · 1 comment
Open

SVG Export does not match sketch #835

matiasw opened this issue Apr 21, 2024 · 1 comment

Comments

@matiasw
Copy link

matiasw commented Apr 21, 2024

Description

When exporting a sketch as SVG from Processing 4.3 with processing.svg, the result is not what the sketch renders in Processing.

Expected Behavior

I expect the exported SVG to match what is drawn by the internal Processing graphics renderer, which is this:
image

Current Behavior

Instead of matching the output from the sketch, what gets exported into the SVG is this:
image

Steps to Reproduce

  1. Draw the Flower of Life pattern recursively. Because the implementation details are irrelevant here (I think?), I am only giving the code for rendering (setup and draw), which is here:
void setup()
{
  strokeWeight(4);
  stroke(200, 0, 0);
  noFill();
  ellipseMode(RADIUS);
  //size(1920, 1080);
  background(0);
  fullScreen();
}

void draw()
{
  beginRecord(SVG, "flower_of_life_field.svg");
  int R = 100;
  Circle c1 = new Circle(new PVector(SCREENWIDTH/2, SCREENHEIGHT/2), R);
  Circle c2 = new Circle(new PVector(c1.center.x + R, c1.center.y), R);
  Circle[] circles = new Circle[2];
  circles[0] = c1;
  circles[1] = c2;
  circles = iterate(circles, 7);
  for (Circle c: circles)
  {
    //println("Draw ellipses at ", c.center.x, c.center.y);
    circle(c.center.x, c.center.y, c.r); 
  }
  endRecord();
}
  1. Observe what is on the screen.
  2. Open the exported SVG and notice that it is different.
  3. Create this bug report.

Your Environment

  • Processing version: 4.3
  • Operating System and OS version: Windows 10 Pro, build 19045.4291

Possible Causes / Solutions

This could also be an issue with the SVG library that Processing uses, in which case I will take this upstream, but I thought to report it here, first.

If I had to guess, I would say this has something to do with ellipseMode(RADIUS).

@matiasw
Copy link
Author

matiasw commented Apr 21, 2024

Ah right, after refreshing my memory about another SVG issue I had: #803

...I got it to work by moving the ellipseMode call between the beginRecord and endRecord.

So, is this just user error on my part? I thought the SVG exporter is supposed to always match what gets drawn to the screen, but maybe I've got that wrong, and it actually just dumps whatever drawing happens between the begin and end calls? In that case, you may close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant