d3ru / eggbotcode

Automatically exported from code.google.com/p/eggbotcode
0 stars 0 forks source link

Support Adobe Illustrator's use of the min-x & min-y parameters in the SVG viewBox attribute #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In some instances, when plotting SVG output from Adobe Illustrator, the pen arm 
will try to go past its drawing limits on the Eggbot (i.e., run up to the head 
or tail stock before drawing).  This can occur when Illustrator produces a SVG 
document which uses the min-x and min-y parameters o the SVG viewBox attribute.

The Eggbot Control extension needs to take this information into account when 
plotting.

Original issue reported on code.google.com by newman.d...@gmail.com on 5 Feb 2011 at 4:00

GoogleCodeExporter commented 9 years ago
As per the eggbot.py code, these two parameters are not currently handled.  At 
the time I added support for the viewBox attribute, I did not have any real 
world examples of viewBox attributes using non-zero values for the min-x and 
min-y parameters.  They appear almost as afterthoughts in the SVG 1.1 spec: 
there is no explanation of them, no examples, and only a very brief note about 
them.

Now that I have a real example in hand, I have added support for them in my 
private copy of eggbot.py.  Once I have a chance to test this on an "egg", I'll 
go ahead and check the change in to the SVN repo.

Original comment by newman.d...@gmail.com on 5 Feb 2011 at 4:04

GoogleCodeExporter commented 9 years ago
See also Issue 33

Original comment by newman.d...@gmail.com on 5 Feb 2011 at 4:06

GoogleCodeExporter commented 9 years ago
Change seems to work in this case (1:1 rescaling).  I've tested with the 
provided sample on my Eggbot.  Changes checked in.

% svn diff eggbot.py
Index: eggbot.py
===================================================================
--- eggbot.py   (revision 198)
+++ eggbot.py   (working copy)
@@ -515,7 +515,6 @@
            return

        # Viewbox handling
-       # Presently ignores minx, miny info (translation)
        # Also ignores the preserveAspectRatio attribute
        viewbox = self.svg.get( 'viewBox' )
        if viewbox:
@@ -523,7 +522,7 @@
            if ( vinfo[2] != 0 ) and ( vinfo[3] != 0 ):
                sx = self.svgWidth / float( vinfo[2] )
                sy = self.svgHeight / float( vinfo[3] )
-               self.svgTransform = parseTransform( 'scale(%f,%f)' % (sx, sy) )
+               self.svgTransform = parseTransform( 'scale(%f,%f) translate(%f,%f)' % (sx, 
sy, -float( vinfo[0] ), -float( vinfo[1] ) ) )

        self.ServoSetup()

Original comment by newman.d...@gmail.com on 5 Feb 2011 at 4:29