SVG2 hatch rendering
Hi!
I've implemented the rendering of SVG2 hatches in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be seen using a test file attached to this message. The rectangles in left columns are filled with hatches, while the ones in right columns are reference images consisting of clipped paths.
What is still to be done is to implement rendering when overflow property is set visible. In addition to this, I have to improve rendering when hatch covered object is zoomed out.
The second problem can be seen in the picture [1]. The cause is aliasing when rendered cairo_pattern_t is applied to a shape. One of the solutions is to adjust applied pattern size to full pixels. This can be achieved by manipulating the transformation applied to the pattern by ink_cairo_pattern_set_matrix in drawing-pattern.cpp:119. The drawback of this rendering hatch paths at displaced positions, what can be visible in case of large shapes. Another solution is to allocate pattern surface of the size of object bounding box and to draw all hatch paths on it. The third one is to increase oversampling and use CAIRO_FILTER_NEAREST for hatches.
What techique do you recommend?
I'd like to add hatches to Swatches and Fill and Stroke dialogs and prepare stock hatches based on ISO 128-50 standard being used in Europe for technical drawing.
As there are more SVG2 elements supported in Inkscape, how should fallback to SVG1.1 look like? Should there be an another output extension? In case of hatches should they be converted to patterns?
Regards Tomasz
On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote:
Hi!
I've implemented the rendering of SVG2 hatches in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be seen using a test file attached to this message. The rectangles in left columns are filled with hatches, while the ones in right columns are reference images consisting of clipped paths.
Looks good!
What is still to be done is to implement rendering when overflow property is set visible. In addition to this, I have to improve rendering when hatch covered object is zoomed out.
The second problem can be seen in the picture [1]. The cause is aliasing when rendered cairo_pattern_t is applied to a shape. One of the solutions is to adjust applied pattern size to full pixels. This can be achieved by manipulating the transformation applied to the pattern by ink_cairo_pattern_set_matrix in drawing-pattern.cpp:119. The drawback of this rendering hatch paths at displaced positions, what can be visible in case of large shapes. Another solution is to allocate pattern surface of the size of object bounding box and to draw all hatch paths on it. The third one is to increase oversampling and use CAIRO_FILTER_NEAREST for hatches.
Picture [1]?
What techique do you recommend?
I don't like rendering at displaced positions. Either the second or third options would be better. Do you have an idea of the performance of these options? Can pattern rendering be handled the same way?
I'd like to add hatches to Swatches and Fill and Stroke dialogs and prepare stock hatches based on ISO 128-50 standard being used in Europe for technical drawing.
Sounds good.
As there are more SVG2 elements supported in Inkscape, how should fallback to SVG1.1 look like? Should there be an another output extension? In case of hatches should they be converted to patterns?
That is a good question. We do need away of being able to select which SVG 2 features should be output, and which should use fallbacks. In the case of hatches, they should be converted to a pattern the size of the object being rendered, I think.
Tav
On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote:
On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote:
I've implemented the rendering of SVG2 hatches in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be seen using a test file attached to this message. The rectangles in left columns are filled with hatches, while the ones in right columns are reference images consisting of clipped paths.
Would one of you be willing to share the test file?
Cheers, Josh
On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote:
On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > I've implemented the rendering of SVG2 hatches > in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be > seen using a test file attached to this message. The rectangles in > left columns are filled with hatches, while the ones in right columns > are reference images consisting of clipped paths.
Would one of you be willing to share the test file?
Look at the attachment to Tomasz's email...
Tav
All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh
On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote:
On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote:
On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > I've implemented the rendering of SVG2 hatches > in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be > seen using a test file attached to this message. The rectangles in > left columns are filled with hatches, while the ones in right columns > are reference images consisting of clipped paths.
Would one of you be willing to share the test file?
Look at the attachment to Tomasz's email...
Tav
Same here. I'm also interested in taking a look at this test file.
On Tue, Aug 5, 2014 at 1:12 PM, Josh Andler <scislac@...400...> wrote:
All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh
On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote:
On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote:
On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > I've implemented the rendering of SVG2 hatches > in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be > seen using a test file attached to this message. The rectangles in > left columns are filled with hatches, while the ones in right columns > are reference images consisting of clipped paths.
Would one of you be willing to share the test file?
Look at the attachment to Tomasz's email...
Tav
Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.cl... _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Attached...
On Tue, 2014-08-05 at 13:16 -0300, Felipe Sanches wrote:
Same here. I'm also interested in taking a look at this test file.
On Tue, Aug 5, 2014 at 1:12 PM, Josh Andler <scislac@...400...> wrote: All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote: > On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: > On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > > I've implemented the rendering of SVG2 hatches > > in lp:~penginsbacon/inkscape/svg-paints-support. How it > works can be > > seen using a test file attached to this message. The > rectangles in > > left columns are filled with hatches, while the ones in > right columns > > are reference images consisting of clipped paths. > > > Would one of you be willing to share the test file? Look at the attachment to Tomasz's email... Tav ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
The image illustrating the aliasing problem is: https://www.dropbox.com/s/r1hlmpwuagdq8cj/hatch_rendering_zoom.png
Do you have an idea of the performance of these options?
I think the main concern here is memory usage. In solution 2 if we had a hatch - filled object occupying whole canvas (let's say 1500x1000px) the cairo pattern surface would take up 5.7MB. The question is if this can be accepted. I'm not sure but I suppose masks and clip paths work this way. The performance of third option does not really differ from what we have in current code. I'll have to play a bit with it to check if results are satisfactory. I think it would be beneficial to turn off antialiasing when rendering the oversampled image. It it possible to do so?
By the way, how can I get to know what SVG area is displayed on canvas?
Can pattern rendering be handled the same way?
Patterns and hatches share the rendering code. They can be handled the same way.
I don't see a way to cleanly export an arbitrary SVG 2 hatch fill/stroke to any of these formats, since they do not have user defined hatch patterns, only pre-defined hatch patterns.
What if I added a hatch palette "WMF" representing the six predefined WMF hatches? They could have an specific attribute like inkscape:wmf-type specifing the hatch type. Any other hatches could be treated as patterns.
As for other file formats, except .dwg, I think it should be safe to convert hatches to patterns for output.
Regards, Tomasz
On Tue, Aug 5, 2014 at 6:26 PM, Tavmjong Bah <tavmjong@...8...> wrote:
Attached...
On Tue, 2014-08-05 at 13:16 -0300, Felipe Sanches wrote:
Same here. I'm also interested in taking a look at this test file.
On Tue, Aug 5, 2014 at 1:12 PM, Josh Andler <scislac@...400...> wrote: All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote: > On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: > On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > > I've implemented the rendering of SVG2 hatches > > in lp:~penginsbacon/inkscape/svg-paints-support. How it > works can be > > seen using a test file attached to this message. The > rectangles in > > left columns are filled with hatches, while the ones in > right columns > > are reference images consisting of clipped paths. > > > Would one of you be willing to share the test file? Look at the attachment to Tomasz's email... Tav
Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.cl...
_______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.cl... _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On Tue, Aug 5, 2014 at 1:12 PM, Tomasz Boczkowski <penginsbacon@...400...> wrote:
The image illustrating the aliasing problem is: https://www.dropbox.com/s/r1hlmpwuagdq8cj/hatch_rendering_zoom.png
Is that possibly related to cairo or pixman version? It doesn't look terrible here... https://www.dropbox.com/s/amnq9c8c64thxrk/hatches.png
Cheers, Josh
Ahh, the attachment was too large to the email is awaiting list moderator. (Who is that?).
Tav
On Tue, 2014-08-05 at 13:16 -0300, Felipe Sanches wrote:
Same here. I'm also interested in taking a look at this test file.
On Tue, Aug 5, 2014 at 1:12 PM, Josh Andler <scislac@...400...> wrote: All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote: > On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: > On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > > I've implemented the rendering of SVG2 hatches > > in lp:~penginsbacon/inkscape/svg-paints-support. How it > works can be > > seen using a test file attached to this message. The > rectangles in > > left columns are filled with hatches, while the ones in > right columns > > are reference images consisting of clipped paths. > > > Would one of you be willing to share the test file? Look at the attachment to Tomasz's email... Tav ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
I think for the devel list it's bryce. I am the admin for the user list.
Cheers, Josh
On Tue, Aug 5, 2014 at 9:28 AM, Tavmjong Bah <tavmjong@...8...> wrote:
Ahh, the attachment was too large to the email is awaiting list moderator. (Who is that?).
Tav
On Tue, 2014-08-05 at 13:16 -0300, Felipe Sanches wrote:
Same here. I'm also interested in taking a look at this test file.
On Tue, Aug 5, 2014 at 1:12 PM, Josh Andler <scislac@...400...> wrote: All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote: > On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: > On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > > I've implemented the rendering of SVG2 hatches > > in lp:~penginsbacon/inkscape/svg-paints-support. How it > works can be > > seen using a test file attached to this message. The > rectangles in > > left columns are filled with hatches, while the ones in > right columns > > are reference images consisting of clipped paths. > > > Would one of you be willing to share the test file? Look at the attachment to Tomasz's email... Tav
Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.cl...
_______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On 05-Aug-2014 09:12, Josh Andler wrote:
All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Me too.
I'm a little unclear on the purpose of hatches which is:
"SVG 2 should support hatchings without the artifacts that patterns currently impose."
Those are continuous lines/curves drawn along arbitrary angles. Anything else?
For what it's worth I don't see any reason to migrate the hatch support in WMF, EMF (,or EMF+, should it ever be implemented, which is dubious since at least one key applications, PPT, drops text when it writes it) from patterns to SVG 2 hatch, since those predefined patterns are all aligned at 0, 45 or 90 degrees to the X axis. (Plus the spec doesn't really say what should happen to those hatches when the coordinate system is rotated, so some apps rotate the hatch and others leave it in the original orientation.)
I don't see a way to cleanly export an arbitrary SVG 2 hatch fill/stroke to any of these formats, since they do not have user defined hatch patterns, only pre-defined hatch patterns. The closest would be to make a bitmap and export that as the fill/stroke, but that is a one way conversion. Most likely SVG 2 hatch is also going to be a problem going into/out of other graphics formats.
What I'm saying is, yes Inkscape should render/manipulate the new hatches, but if portability is a concern, it might be best to guide users away from employing this feature when making new drawings. Otherwise there will be the inevitable "why does my hatch look terrible when I save to X" problems.
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
05 авг. 2014 г. 20:34 пользователь "mathog" <mathog@...1176...> написал:
I'm a little unclear on the purpose of hatches
The spec explains that:
"Hatches are new in SVG 2. They were added to allow the kinds of patterns required for mapping, engraving, etc. where continuous lines are needed."
Also, hatch elments can be converted to pattern elements. Can you safely convert patterns to WMF/EMF? There you are.
Alex
On 05-Aug-2014 09:57, Alexandre Prokoudine wrote:
05 авг. 2014 г. 20:34 пользователь "mathog" <mathog@...1176...> написал:
I'm a little unclear on the purpose of hatches
The spec explains that:
"Hatches are new in SVG 2. They were added to allow the kinds of patterns required for mapping, engraving, etc. where continuous lines are needed."
Also, hatch elments can be converted to pattern elements. Can you safely convert patterns to WMF/EMF? There you are.
Which brings me back to "the purpose of hatches". As far as I can tell their primary function is to make it easier to place lines into rectangular elements of a grid pattern so that the lines "line up" as desired between adjacent elements. No nicks or jags at the intersections, which can usually be removed now, but getting the pattern right to do so takes some work. Or they can be done with patterns and clipping for fill, but not for stroke.
The examples here:
http://www.w3.org/TR/SVG2/pservers.html#Hatches
were not very informative for me, it wasn't obvious what the improvement is over what we already have in SVG. There isn't, as far as I can see, one example, showing old and new, demonstrating why these new hatches are an improvement. I'm not saying they aren't, just that it isn't explained very well why this is worth the effort.
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
The mailing list SF blocked it due to the size of the attachment. I've passed it through so should be in your box now.
On Tue, Aug 05, 2014 at 09:12:01AM -0700, Josh Andler wrote:
All I saw was your reply to him. Nothing directly from him or via the list in my inbox or spam folder.
Cheers, Josh
On Tue, Aug 5, 2014 at 9:09 AM, Tavmjong Bah <tavmjong@...8...> wrote:
On Tue, 2014-08-05 at 08:56 -0700, Josh Andler wrote:
On Tue, Aug 5, 2014 at 7:54 AM, Tavmjong Bah <tavmjong@...8...> wrote: On Tue, 2014-08-05 at 16:15 +0200, Tomasz Boczkowski wrote: > I've implemented the rendering of SVG2 hatches > in lp:~penginsbacon/inkscape/svg-paints-support. How it works can be > seen using a test file attached to this message. The rectangles in > left columns are filled with hatches, while the ones in right columns > are reference images consisting of clipped paths.
Would one of you be willing to share the test file?
Look at the attachment to Tomasz's email...
Tav
Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.cl...
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (7)
-
Alexandre Prokoudine
-
Bryce Harrington
-
Felipe Sanches
-
Josh Andler
-
mathog
-
Tavmjong Bah
-
Tomasz Boczkowski