Commit 3e6e391a authored by Dom Lachowicz's avatar Dom Lachowicz

fix some gradient handling

parent a31e24b3
......@@ -469,7 +469,7 @@ rsvg_parse_path_data (RSVGParsePathCtx *ctx, const char *data)
#else
/* rule: even-numbered params are x-relative, odd-numbered
are y-relative */
if (ctx->param == 0 || (ctx->param % 2 ==0))
if (ctx->param == 0 || (ctx->param % 2 == 0))
val += ctx->cpx;
else
val += ctx->cpy;
......
......@@ -63,7 +63,8 @@
/*
* This is configurable at runtime
*/
#define RSVG_DPI 90.0
#define RSVG_DEFAULT_DPI 90.0
static double internal_dpi = RSVG_DEFAULT_DPI;
typedef struct {
double affine[6];
......@@ -267,13 +268,6 @@ rsvg_start_svg (RsvgHandle *ctx, const xmlChar **atts)
(* ctx->size_func) (&new_width, &new_height, ctx->user_data);
}
if (new_width <= 0 || new_height <= 0)
{
/* FIXME: GError here? */
g_warning ("rsvg_start_svg: can't render 0-sized SVG");
return;
}
/* set these here because % are relative to viewbox */
ctx->width = new_width;
ctx->height = new_height;
......@@ -284,9 +278,14 @@ rsvg_start_svg (RsvgHandle *ctx, const xmlChar **atts)
y_zoom = (height < 0 || new_height < 0) ? 1 : (double) new_height / height;
}
else
{
{
#if 1
x_zoom = (width < 0 || new_width < 0) ? 1 : (double) width / new_width;
y_zoom = (height < 0 || new_height < 0) ? 1 : (double) height / new_height;
#else
x_zoom = (width < 0 || new_width < 0) ? 1 : (double) new_width / width;
y_zoom = (height < 0 || new_height < 0) ? 1 : (double) new_height / height;
y_zoom = (height < 0 || new_height < 0) ? 1 : (double) new_height / height;
#endif
/* reset these so that we get a properly sized SVG and not a huge one */
new_width = (width == -1 ? new_width : width);
......@@ -297,6 +296,15 @@ rsvg_start_svg (RsvgHandle *ctx, const xmlChar **atts)
state = &ctx->state[ctx->n_state - 1];
art_affine_scale (state->affine, x_zoom, y_zoom);
#if 0
if (vbox_x != 0. || vbox_y != 0.)
{
double affine[6];
art_affine_translate (affine, vbox_x, vbox_y);
art_affine_multiply (state->affine, affine, state->affine);
}
#endif
if (new_width < 0 || new_height < 0)
{
g_warning ("rsvg_start_svg: width and height not specified in the SVG, nor supplied by the size callback");
......@@ -1588,8 +1596,7 @@ rsvg_gradient_stop_handler_end (RsvgSaxHandler *self, const xmlChar *name)
if (ctx->handler != NULL)
{
ctx->handler->free (ctx->handler);
/* hack for adobe illustrator 9 */
ctx->handler = (z->parent ? &z->parent->super : NULL);
ctx->handler = &z->parent->super;
}
}
}
......@@ -2392,7 +2399,7 @@ rsvg_start_element (void *data, const xmlChar *name, const xmlChar **atts)
else if (!strcmp ((char *)name, "polyline"))
rsvg_start_polyline (ctx, atts);
/* HACK for Adobe 9 */
/* */
else if (!strcmp ((char *)name, "linearGradient"))
rsvg_start_linear_gradient (ctx, atts);
else if (!strcmp ((char *)name, "radialGradient"))
......@@ -2505,6 +2512,8 @@ static xmlSAXHandler rsvgSAXHandlerStruct = {
rsvg_error_cb, /* xmlParserError */
rsvg_error_cb, /* xmlParserFatalError */
NULL, /* getParameterEntity */
rsvg_characters, /* cdataCallback */
NULL /* */
};
GQuark
......@@ -2540,7 +2549,7 @@ rsvg_handle_new (void)
handle->defs = rsvg_defs_new ();
handle->handler_nest = 0;
handle->entities = g_hash_table_new (g_str_hash, g_str_equal);
handle->dpi = RSVG_DPI;
handle->dpi = internal_dpi;
handle->css_props = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
......@@ -2550,6 +2559,23 @@ rsvg_handle_new (void)
return handle;
}
/**
* rsvg_set_dpi
* @dpi: Dots Per Inch (aka Pixels Per Inch)
*
* Sets the DPI for the all future outgoing pixbufs. Common values are
* 72, 90, and 300 DPI. Passing a number <= 0 to #dpi will
* reset the DPI to whatever the default value happens to be.
*/
void
rsvg_set_dpi (double dpi)
{
if (dpi <= 0.)
internal_dpi = RSVG_DEFAULT_DPI;
else
internal_dpi = dpi;
}
/**
* rsvg_handle_set_dpi
* @handle: An #RsvgHandle
......@@ -2565,7 +2591,7 @@ rsvg_handle_set_dpi (RsvgHandle * handle, double dpi)
g_return_if_fail (handle != NULL);
if (dpi <= 0.)
handle->dpi = RSVG_DPI;
handle->dpi = internal_dpi;
else
handle->dpi = dpi;
}
......
......@@ -42,6 +42,8 @@ typedef void (* RsvgSizeFunc) (gint *width,
gpointer user_data);
void rsvg_set_dpi (double dpi);
RsvgHandle *rsvg_handle_new (void);
void rsvg_handle_set_dpi (RsvgHandle * handle, double dpi);
void rsvg_handle_set_size_callback (RsvgHandle *handle,
......
......@@ -119,6 +119,12 @@ main (int argc, char **argv)
poptFreeContext (popt_context);
if (!pixbuf)
{
fprintf (stderr, "Error displaying pixbuf!\n");
return 1;
}
view_pixbuf (pixbuf);
/* run the gtk+ main loop */
......
This diff is collapsed.
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg
style="fill:#000000;fill-opacity:0.5;stroke:none"
width="595.275591"
height="841.889764"
id="svg1"
sodipodi:docbase="/home/waldgeist/"
sodipodi:docname="/home/waldgeist/gnomefoot.svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs
id="defs3">
<linearGradient
id="linearGradient39">
<stop
style="stop-color:#000;stop-opacity:1;"
offset="0"
id="stop40" />
<stop
style="stop-color:#fff;stop-opacity:1;"
offset="1"
id="stop41" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient39"
id="linearGradient42"
x1="-0.964639"
y1="0.195312"
x2="1.1277"
y2="0.320312" />
</defs>
<sodipodi:namedview
id="base" />
<path
style="fill:#7f7f7f; fill-rule:evenodd; stroke-linejoin:miter; stroke-linecap:butt; fill-opacity:0.498039; "
id="path5"
d="M 239.276 183.943 C 239.185 170.465 209.065 178.234 209.358 183.789 C 209.754 210.681 184.672 195.1 184.777 185.621 C 184.834 169.243 236.3 157.838 236.425 132.808 C 236.001 100.484 141.031 114.105 142.047 159.871 C 142.797 190.627 174.364 218.458 201.189 218.367 C 222.606 218.677 239.35 194.692 239.276 183.943 z "
sodipodi:nodetypes="ccccccs"
transform="matrix(4.106,0,0,4.106,-504.521,-180.649)" />
<path
style="opacity:1; fill:#7f7f7f; fill-rule:evenodd; stroke-linejoin:miter; stroke-linecap:butt; fill-opacity:0.498039; "
id="path14"
d="M 128.261 117.115 C 128.407 106.159 146.425 102.095 146.101 126.037 C 145.641 145.722 128.332 126.411 128.261 117.115 z "
sodipodi:nodetypes="ccc"
transform="matrix(4.106,0,0,4.106,-491.324,-213.639)" />
<path
style="fill:#7f7f7f; fill-rule:evenodd; stroke-linejoin:miter; stroke-linecap:butt; "
id="path7"
d="M 152.86 91.9863 C 153.511 107.416 171.218 121.742 171.478 96.0288 C 171.718 73.3601 152.784 78.3235 152.86 91.9863 z "
sodipodi:nodetypes="ccc"
transform="matrix(4.106,0,0,4.106,-502.635,-180.649)" />
<path
style="fill:#7f7f7f; fill-rule:evenodd; stroke-linejoin:miter; stroke-linecap:butt; "
id="path8"
d="M 231.257 83.7835 C 232.002 68.3487 209.646 69.7136 209.578 89.7006 C 209.744 114.149 229.402 115.161 231.257 83.7835 z "
transform="matrix(4.106,0,0,4.106,-618.253,-203.268)"
sodipodi:nodetypes="ccc" />
<path
style="fill:#7f7f7f; fill-rule:evenodd; stroke-linejoin:miter; stroke-linecap:butt; "
id="path9"
d="M 215.036 93.9947 C 215.008 76.142 229.604 61.6018 245.233 61.8596 C 255.998 61.8579 258.759 67.0836 258.801 72.7754 C 258.289 91.8945 215.305 127.966 215.036 93.9947 z "
sodipodi:nodetypes="cccc"
transform="matrix(4.106,0,0,4.106,-504.521,-180.649)" />
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [
<!ENTITY st3 "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
<!ENTITY st4 "fill:none;stroke-width:10;">
<!ENTITY st5 "fill:none;stroke:#FB0F0C;stroke-width:6;stroke-dasharray:12;">
]>
<svg width="103.62pt" height="118.511pt" viewBox="0 0 103.62 118.511" xml:space="preserve">
<g id="Layer_x0020_1" style="&st3;">
<g>
<path style="&st4;" d="M96.706,49.537H6.397V5h90.309v44.537z"/>
<path style="&st5;" d="M96.706,49.537H6.397V5h90.309v44.537z"/>
</g>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [
<!ENTITY st0 "fill:url(#aigrd1);">
<!ENTITY st1 "fill:url(#aigrd2);">
<!ENTITY st2 "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
]>
<svg width="91.722pt" height="109.144pt" viewBox="0 0 91.722 109.144" xml:space="preserve">
<g id="Layer_x0020_1" style="&st2;">
<linearGradient id="aigrd1" gradientUnits="userSpaceOnUse" x1="0.5" y1="22.7686" x2="90.8091" y2="22.7686">
<stop offset="0" style="stop-color:#FB0F0C"/>
<stop offset="0.2" style="stop-color:#F7F619"/>
<stop offset="0.4" style="stop-color:#168638"/>
<stop offset="0.6" style="stop-color:#1A9ABF"/>
<stop offset="0.8" style="stop-color:#19037A"/>
<stop offset="1" style="stop-color:#EF097C"/>
</linearGradient>
<path style="&st0;" d="M90.809,45.037H0.5V0.5h90.309v44.537z"/>
<radialGradient id="aigrd2" cx="46.0679" cy="86.376" r="35.6003" fx="46.0679" fy="86.376" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#FB0F0C"/>
<stop offset="0.2" style="stop-color:#F7F619"/>
<stop offset="0.4" style="stop-color:#168638"/>
<stop offset="0.6" style="stop-color:#1A9ABF"/>
<stop offset="0.8" style="stop-color:#19037A"/>
<stop offset="1" style="stop-color:#EF097C"/>
</radialGradient>
<path style="&st1;" d="M91.222,108.644H0.913V64.107h90.309v44.536z"/>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [
<!ENTITY st0 "fill:none;stroke:#0C3D1B;stroke-width:2;">
<!ENTITY st1 "fill:none;stroke:#0C3D1B;stroke-width:3;">
<!ENTITY st2 "fill:#F7F619;stroke:none;">
<!ENTITY st3 "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
<!ENTITY st4 "fill:none;stroke-width:10;">
<!ENTITY st5 "fill:none;stroke:#FB0F0C;stroke-width:6;stroke-dasharray:12;">
]>
<svg width="103.62pt" height="118.511pt" viewBox="0 0 103.62 118.511" xml:space="preserve">
<g id="Layer_x0020_1" style="&st3;">
<g>
<path style="&st4;" d="M96.706,49.537H6.397V5h90.309v44.537z"/>
<path style="&st5;" d="M96.706,49.537H6.397V5h90.309v44.537z"/>
</g>
<g>
<path style="&st2;" d="M97.119,113.144H6.81V68.607h90.309v44.536z"/>
<path style="&st1;" d="M96.493,112.497c-8.119,7.87-10.681-1.129-21.987-1.129c-11.321,0-11.321-0.161-22.643-0.161c-11.431,0-11.431,0.274-22.862,0.274c-11.096,0-11.873,7.083-19.644-0.837c-7.92-8.072-1.857-8.809-1.857-20.117
c0-10.96-11.047-16.857-3.177-24.485c8.118-7.869,13.793,4.604,25.1,4.604c11.322,0,11.322,1.887,22.643,1.887c11.431,0,11.431-7.188,22.861-7.188c11.096,0,16.549-6.747,24.32,1.173c7.92,8.071-3.196,13.387-0.981,24.476c2.227,11.146,6.096,13.875-1.773,21.503
z"/>
<path style="&st0;" d="M96.316,112.34c-2.5,2.497-2.731-0.609-6.265-0.609c-3.567,0-3.567,5.781-7.135,5.781c-3.503,0-3.503-7.897-7.006-7.897c-3.56,0-3.56,1.516-7.119,1.516c-3.518,0-3.518,5.048-7.036,5.048c-3.487,0-3.487-6.763-6.976-6.763
c-3.475,0-3.475,2.077-6.948,2.077c-3.487,0-3.487,3.427-6.975,3.427c-3.543,0-3.543-0.388-7.086-0.388c-3.503,0-3.503-5.024-7.007-5.024c-3.346,0-3.346,4.088-6.692,4.088c-3.405,0-3.405,2.885-6.81,2.885c-3.226,0-5.816,0.346-7.894-2.122
c-2.468-2.932,3.471-5.046,3.471-8.878c0-3.788-4.413-3.788-4.413-7.575s3.525-3.787,3.525-7.574c0-3.688-1.57-3.688-1.57-7.376c0-3.644,0.567-3.644,0.567-7.288c0-3.529-3.258-5.188-0.761-7.682c2.5-2.497,4.156,2.143,7.69,2.143
c3.567,0,3.567-0.037,7.135-0.037c3.503,0,3.503-3.677,7.005-3.677c3.56,0,3.56-1.032,7.119-1.032c3.518,0,3.518,7.131,7.036,7.131c3.488,0,3.488-3.431,6.975-3.431c3.475,0,3.475-0.978,6.949-0.978c3.487,0,3.487,1.646,6.975,1.646
c3.543,0,3.543,3.37,7.086,3.37c3.504,0,3.504-7.337,7.008-7.337c3.346,0,3.346,6.752,6.691,6.752c3.405,0,3.405-5.104,6.81-5.104c3.227,0,1.303,1.294,3.38,3.762c2.468,2.932,4.714,1.246,4.714,5.078c0,3.787-1.249,3.787-1.249,7.575
c0,3.787-4.209,3.787-4.209,7.574c0,3.688,2.684,3.688,2.684,7.376c0,3.645,4.705,3.054,5.258,6.655c0.507,3.303-2.43,4.395-4.928,6.888z"/>
</g>
</g>
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment