return parsed_value;
}
+ /**
+ * That is according to Units in here
+ *
+ * https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
+ */
if (type == SVG_PARSER_LENGTH_VERTICAL)
max = svg_parse.global.height;
else if (type == SVG_PARSER_LENGTH_HORIZONTAL)
max = svg_parse.global.width;
- //TODO: what about radial?
+ else if (type == SVG_PARSER_LENGTH_OTHER)
+ max = sqrt(pow(svg_parse.global.height, 2) +
+ pow(svg_parse.global.width, 2)) / sqrt(2.0);
if (strstr(str, "cm"))
parsed_value = parsed_value * 35.43307;
return parsed_value;
}
-static inline int
+static inline double
_to_offset(const char *str)
{
char *end = NULL;
}
#define ELLIPSE_DEF(Name, Field, Type) \
- { #Name, Type, sizeof (#Name) + sizeof (Type), offsetof(Svg_Ellipse_Node, Field)}
+ { #Name, Type, sizeof (#Name), offsetof(Svg_Ellipse_Node, Field)}
static const struct {
const char *tag;
}
#define RECT_DEF(Name, Field, Type) \
- { #Name, Type, sizeof (#Name) + sizeof(Type), offsetof(Svg_Rect_Node, Field)}
+ { #Name, Type, sizeof (#Name), offsetof(Svg_Rect_Node, Field)}
static const struct {
const char *tag;
}
#define LINE_DEF(Name, Field, Type) \
- { #Name, Type, sizeof (#Name) + sizeof (Type), offsetof(Svg_Line_Node, Field)}
+ { #Name, Type, sizeof (#Name), offsetof(Svg_Line_Node, Field)}
static const struct {
const char *tag;
static void
_handle_radial_cx_attr(Svg_Radial_Gradient* radial, const char *value)
{
- radial->cx = _to_double(value, SVG_PARSER_LENGTH_HORIZONTAL);
+ radial->cx = _gradient_to_double(value, SVG_PARSER_LENGTH_HORIZONTAL);
if (!svg_parse.gradient.fx_parsed)
radial->fx = radial->cx;
}
static void
_handle_radial_cy_attr(Svg_Radial_Gradient* radial, const char *value)
{
- radial->cy = _to_double(value, SVG_PARSER_LENGTH_VERTICAL);
+ radial->cy = _gradient_to_double(value, SVG_PARSER_LENGTH_VERTICAL);
if (!svg_parse.gradient.fy_parsed)
radial->fy = radial->cy;
}
static void
_handle_radial_fx_attr(Svg_Radial_Gradient* radial, const char *value)
{
- radial->fx = _to_double(value, SVG_PARSER_LENGTH_HORIZONTAL);
+ radial->fx = _gradient_to_double(value, SVG_PARSER_LENGTH_HORIZONTAL);
svg_parse.gradient.fx_parsed = EINA_TRUE;
}
static void
_handle_radial_fy_attr(Svg_Radial_Gradient* radial, const char *value)
{
- radial->fy = _to_double(value, SVG_PARSER_LENGTH_VERTICAL);
+ radial->fy = _gradient_to_double(value, SVG_PARSER_LENGTH_VERTICAL);
svg_parse.gradient.fy_parsed = EINA_TRUE;
}
static void
_handle_radial_r_attr(Svg_Radial_Gradient* radial, const char *value)
{
- radial->r = _to_double(value, SVG_PARSER_LENGTH_OTHER);
+ radial->r = _gradient_to_double(value, SVG_PARSER_LENGTH_OTHER);
}
-
typedef void (*Radial_Method)(Svg_Radial_Gradient *radial, const char *value);
#define RADIAL_DEF(Name) \
{
grad->ref = _id_from_href(value);
}
- else if (!strcmp(key, "gradientUnits") && !strcmp(value, "userSpaceOnUse"))
+ else if (!strcmp(key, "gradientUnits") && !strcmp(value, "objectBoundingBox"))
{
- grad->user_space = EINA_TRUE;
+ grad->user_space = EINA_FALSE;
}
return EINA_TRUE;
Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient));
grad->type = SVG_RADIAL_GRADIENT;
+ grad->user_space = EINA_TRUE;
grad->radial = calloc(1, sizeof(Svg_Radial_Gradient));
svg_parse.gradient.fx_parsed = EINA_FALSE;
{
grad->ref = _id_from_href(value);
}
- else if (!strcmp(key, "gradientUnits") && !strcmp(value, "userSpaceOnUse"))
+ else if (!strcmp(key, "gradientUnits") && !strcmp(value, "objectBoundingBox"))
{
grad->user_space = EINA_TRUE;
}
unsigned int i;
grad->type = SVG_LINEAR_GRADIENT;
+ grad->user_space = EINA_TRUE;
grad->linear = calloc(1, sizeof(Svg_Linear_Gradient));
/**
* Default value of x2 is 100%
}
else if (g->type == SVG_RADIAL_GRADIENT)
{
+ /**
+ * That is according to Units in here
+ *
+ * https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
+ */
+ int radius = sqrt(pow(r.h, 2) + pow(r.w, 2)) / sqrt(2.0);
grad_obj = evas_vg_gradient_radial_add(NULL);
- evas_vg_gradient_radial_center_set(grad_obj, g->radial->cx, g->radial->cy);
- evas_vg_gradient_radial_radius_set(grad_obj, g->radial->r);
- evas_vg_gradient_radial_focal_set(grad_obj, g->radial->fx, g->radial->fy);
+ evas_vg_gradient_radial_center_set(grad_obj, g->radial->cx * r.w + r.x, g->radial->cy * r.h + r.y);
+ evas_vg_gradient_radial_radius_set(grad_obj, g->radial->r * radius);
+ evas_vg_gradient_radial_focal_set(grad_obj, g->radial->fx * r.w + r.x, g->radial->fy * r.h + r.y);
}
else
{