|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
SVG(Inkscape?) Misunderstanding?I apologize for this being possibly off topic. I'm trying to use Cairo
to draw an SVG file (the one attached for example). And something's not going right. I must be missing something obvious. When rendered as an icon from Inkscape, I end up with a 16x16 icon, with 9 little orange gradient squares. They're nicely pixel aligned to keep it crisp. If I understand the SVG correctly, I should be able to do the following cairo stuff in pseudo code: // These values derived from the height/width and the viewBox of the root svg node scale( cr , 16 / 64.424 , 16 / 51.278 ); // apply the transform found at the g4466 node matrix.xx = 0.6031636; matrix.yx = 0; matrix.xy = 0; matrix.yy = 0.6190702; matrix.x0 = 7.87836; matrix.y0 = 5.1860675; set_matrix( cr , &matrix ); // rect3654 rectangle(cr, -5.9716139, -15.317435, -5.9716139 + 28.360464, -15.317435 + 27.631762); //set a source and fill after this Unfortunately, this doesn't end up right. If I work the numbers by pencil myself, at least for the origin of the rectangle, I get: (-5.9716139 * 0.6031636 + 7.87836) * (16 / 64.424) --> 1.06209 (-15.317435 * 0.6190702 + 5.1860675) * (16 / 51.278) --> -1.34061 I could almost believe that the 1.06 was just rounding error (rather severe actually), but the y value shouldn't be negative at all, and it's not at all near integral. I don't know what I'm doing wrong. I'm wondering at this point, if I've mixed something in the application of viewBox. Any helps or hints would be hugely appreciated. -- Travis Griggs Objologist "Is success the potential of what could be, or the reality of what is?" _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: SVG(Inkscape?) Misunderstanding?Excerpts from Travis Griggs's message of Thu Oct 22 14:45:02 -0700 2009:
> When rendered as an icon from Inkscape, I end up with a 16x16 icon, > with 9 little orange gradient squares. They're nicely pixel aligned to > keep it crisp. If I understand the SVG correctly, I should be able to > do the following cairo stuff in pseudo code: I haven't tried to understand your SVG nor your pseudo-code yet, but I ran our litttle svg2png utility (that uses librsvg) and the result seems reasonable. Then I ran: cairo-trace svg2png array.svg array.png and achieved the attached output. Hopefully it will be enlightening. -Carl _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
SVG viewBox misunderstandingCarl's response, and some further discussion in irc helped me get to
the bottom of things, kind of. Carl's svg2png trace showed that the svg file does represent the icon properly, which isn't a surprise (I've attached a lighter/trimmed version of it again). What the trace shows is a singular matrix set: [0.141041 0 1.842245 0 0.144761 3.217366 ] What I don't get is how it came to that conclusion, *in particular* the yy value. The 3 inputs from the svg file are: viewBox ( 0 0 64.424 51.278 ) width&height 16 additional transform matrix (0.6031636, 0, 0, 0.6190702, 7.87836, 5.1860675) If one runs the number for the XX component of the matrix, it should be 16 / 64.424 * 0.6031636. Which it is. It's correct. But if one does 16 / 51.278 * 0.619072, it is NOT 0.144761. What seems to be correct, is to ignore the height of the viewBox attribute, and use the width as the height instead: 16 / 64.424 * 0.619072. So what I don't understand, and am begging any SVG gurus to explain, is why the 64.424 is used for both width and height. That's obviously what I'm supposed to have done here, but I don't get *why*. I looked around in librsvg a *little* and didn't see anything obvious right away. TIA -- Travis Griggs Objologist My Other Machine runs OSX. But then... so does this one. _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
| Free embeddable forum powered by Nabble | Forum Help |