benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 241 forks source link

pixelDensity(2) with SVG creates incorrect viewport in the file #693

Open mrbbp opened 1 year ago

mrbbp commented 1 year ago
## Description i was playing around with svg export and curve drawing. I'm working on MacOS with a retina display, therefore i add pixelDensity to improve display.

Expected Behavior

the document should stay in the viewbox

Current Behavior

When we export to svg, there is a glitch on the output file. there is a transform="scale(2,2)" on the exported shape. I understand why, but in fact it's useless, because it's vector shape exported. the document is defined with the right definition (created with size(width, height) in the script) by adding a transform, it modify the preview and the size of the shape in the viewbox.

Steps to Reproduce

import processing.svg.*;

void setup() {
  size(400,400, SVG, "filename_without_pixeldensity.svg");
  //pixelDensity(2);
}

void draw() {
  circle(width/2,height/2, width/2);
  exit();
}

Your Environment

Possible Causes / Solutions

Remove the transform="scale(2,2)" on each group of shape or adjust the document size (withand height) according to the pixelDensity instruction in the <svg> tag to have a correct preview and document viewbox.

benfry commented 1 year ago

Ok, though I think I'd recommend just not using pixelDensity() in these cases.