grad->id = _copy_id(from->id);
grad->ref = _copy_id(from->ref);
grad->spread = from->spread;
+ grad->use_percentage = from->use_percentage;
grad->user_space = from->user_space;
grad->stops = _clone_grad_stops(from->stops);
if (grad->type == SVG_LINEAR_GRADIENT)
linear->y2 = _gradient_to_double(loader->svg_parse, value, SVG_PARSER_LENGTH_VERTICAL);
}
+static void
+_recalc_linear_x1_attr(Evas_SVG_Loader *loader, Svg_Linear_Gradient* linear, Eina_Bool user_space)
+{
+ if (!user_space)
+ {
+ linear->x1 = linear->x1 * loader->svg_parse->global.width;
+ }
+}
+
+static void
+_recalc_linear_y1_attr(Evas_SVG_Loader *loader, Svg_Linear_Gradient* linear, Eina_Bool user_space)
+{
+ if (!user_space)
+ {
+ linear->y1 = linear->y1 * loader->svg_parse->global.height;
+ }
+}
+
+static void
+_recalc_linear_x2_attr(Evas_SVG_Loader *loader, Svg_Linear_Gradient* linear, Eina_Bool user_space)
+{
+ if (!user_space)
+ {
+ linear->x2 = linear->x2 * loader->svg_parse->global.width;
+ }
+}
+
+static void
+_recalc_linear_y2_attr(Evas_SVG_Loader *loader, Svg_Linear_Gradient* linear, Eina_Bool user_space)
+{
+ if (!user_space)
+ {
+ linear->y2 = linear->y2 * loader->svg_parse->global.height;
+ }
+}
+
typedef void (*Linear_Method)(Evas_SVG_Loader *loader, Svg_Linear_Gradient *linear, const char *value);
+typedef void (*Linear_Method_Recalc)(Evas_SVG_Loader *loader, Svg_Linear_Gradient *linear, Eina_Bool user_space);
#define LINEAR_DEF(Name) \
- { #Name, sizeof (#Name), _handle_linear_##Name##_attr}
+ { #Name, sizeof (#Name), _handle_linear_##Name##_attr, _recalc_linear_##Name##_attr}
static const struct {
const char *tag;
int sz;
- Linear_Method tag_handler;;
+ Linear_Method tag_handler;
+ Linear_Method_Recalc tag_recalc;
} linear_tags[] = {
LINEAR_DEF(x1),
LINEAR_DEF(y1),
{
Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient));
loader->svg_parse->style_grad = grad;
+ unsigned int i;
grad->type = SVG_LINEAR_GRADIENT;
grad->user_space = EINA_FALSE;
eina_simple_xml_attributes_parse(buf, buflen,
_attr_parse_linear_gradient_node, loader);
+ for (i = 0; i < sizeof (linear_tags) / sizeof(linear_tags[0]); i++)
+ linear_tags[i].tag_recalc(loader, grad->linear, grad->user_space);
+
+ grad->use_percentage = EINA_TRUE;
+
return loader->svg_parse->style_grad;
}
if (g->type == SVG_LINEAR_GRADIENT)
{
grad_obj = efl_add(EFL_CANVAS_VG_GRADIENT_LINEAR_CLASS, parent);
- efl_gfx_gradient_linear_start_set(grad_obj, g->linear->x1 * r.w + r.x, g->linear->y1 * r.h + r.y);
- efl_gfx_gradient_linear_end_set(grad_obj, g->linear->x2 * r.w + r.x, g->linear->y2 * r.h + r.y);
+
+ if (g->use_percentage)
+ {
+ g->linear->x1 = g->linear->x1 * r.w + r.x;
+ g->linear->y1 = g->linear->y1 * r.h + r.y;
+ g->linear->x2 = g->linear->x2 * r.w + r.x;
+ g->linear->y2 = g->linear->y2 * r.h + r.y;
+ }
+ efl_gfx_gradient_linear_start_set(grad_obj, g->linear->x1, g->linear->y1);
+ efl_gfx_gradient_linear_end_set(grad_obj, g->linear->x2, g->linear->y2);
}
else if (g->type == SVG_RADIAL_GRADIENT)
{
if (!grad->linear) goto oom_error;
efl_gfx_gradient_linear_start_get(vg, &grad->linear->x1, &grad->linear->y1);
efl_gfx_gradient_linear_end_get(vg, &grad->linear->x2, &grad->linear->y2);
+ grad->use_percentage = EINA_FALSE;
}
else
{