Hi.
I'm playing around with the SVG generator at the moment, and I wonder if
what it does for shapes that aren't anti-aliased is correct. I am using
some code that renders HTML to a Graphics2D. This HTML:
<div style="width: 3px; height: 3px; background: red;
border: 1px solid black"/>
approximately results in these drawing commands:
g2d.setColor(Color.RED);
g2d.drawRect(8, 8, 5, 5);
g2d.setColor(Color.BLACK);
g2d.drawLine(8, 8, 12, 8);
g2d.drawLine(8, 8, 8, 12);
g2d.drawLine(8, 12, 12, 12);
g2d.drawLine(12, 8, 12, 12);
Because anti-aliasing is off, this results in these pixels being drawn:
B B B B B
B r r r B
B r r r B
B r r r B
B B B B B
When drawing this on an SVGGraphics2D, I get this approximate SVG output:
<g shape-rendering="auto">
<rect x="8" y="8" width="5" height="5" fill="red"/>
<line x1="8" y1="8" x2="12" y="8" stroke="black"/>
<line x1="8" y1="8" x2="8" y="12" stroke="black"/>
<line x1="8" y1="12" x2="12" y="12" stroke="black"/>
<line x1="12" y1="8" x2="12" y="12" stroke="black"/>
</g>
When viewed without zooming in, this looks identical to the HTML
rendering, because of the "normalisation" of the coordinates. When
zoomed in to x2, the pixels look like this:
B B B B B B B B B B
B B B B B B B B B B r
B B r r r r r r B B r
B B r r r r r r B B r
B B r r r r r r B B r
B B r r r r r r B B r
B B r r r r r r B B r
B B r r r r r r B B r
B B B B B B B B B B r
B B B B B B B B B B r
r r r r r r r r r r
This is (obviously?) because the coordinate normalisation doesn't happen
because there's no problem of them falling between pixel boundaries with
the 1px width stroke.
My question is: should the SVGGraphics2D be transforming the output so
that it actually represents what is painted after normalisation? In
this example, it would be:
<g shape-rendering="geometricPrecision">
<rect x="8" y="8" width="5" height="5" fill="red"/>
<line x1="8.5" y1="8.5" x2="12.5" y="8.5" stroke="black"/>
<line x1="8.5" y1="8.5" x2="8.5" y="12.5" stroke="black"/>
<line x1="8.5" y1="12.5" x2="12.5" y="12.5" stroke="black"/>
<line x1="12.5" y1="8.5" x2="12.5" y="12.5" stroke="black"/>
</g>
Or perhaps some other way to preserve the normalised positions whether
zoomed in or not (since it might not be desirable to turn on
shape-rendering="geometricPrecision" if the shapes should actually be
drawn without anti-aliasing, according to the rendering hints set).
Thanks,
Cameron
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]