GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit d6a016b4 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

support optional center coordinates for the "rotate" transformations.

2004-08-21  Sven Neumann  <sven@gimp.org>

	* app/vectors/gimpvectors-import.c (parse_svg_transform): support
	optional center coordinates for the "rotate" transformations.
	(parse_svg_transform): apply transformations in reverse order. The
	SVG spec is rather confusing here.
parent 323e7f4c
2004-08-21 Sven Neumann <sven@gimp.org>
* app/vectors/gimpvectors-import.c (parse_svg_transform): support
optional center coordinates for the "rotate" transformations.
(parse_svg_transform): apply transformations in reverse order. The
SVG spec is rather confusing here.
2004-08-21 Sven Neumann <sven@gimp.org>
* app/vectors/gimpbezierstroke.c (gimp_bezier_stroke_arcto): fixed
......
......@@ -545,7 +545,8 @@ svg_handler_group_start (SvgHandler *handler,
handler->transform = g_memdup (&matrix, sizeof (GimpMatrix3));
#ifdef DEBUG_VECTORS_IMPORT
g_printerr ("%s: %g %g %g %g %g %g %g %g %g\n", handler->id,
g_printerr ("transform %s: %g %g %g %g %g %g %g %g %g\n",
handler->id ? handler->id : "(null)",
handler->transform->coeff[0][0],
handler->transform->coeff[0][1],
handler->transform->coeff[0][2],
......@@ -1089,16 +1090,20 @@ static gboolean
parse_svg_transform (const gchar *value,
GimpMatrix3 *matrix)
{
gint i;
gchar keyword[32];
gdouble args[6];
gint n_args;
gint key_len;
gint i;
gimp_matrix3_identity (matrix);
for (i = 0; value[i]; i++)
{
GimpMatrix3 trafo;
gchar keyword[32];
gdouble args[6];
gint n_args;
gint key_len;
gimp_matrix3_identity (&trafo);
/* skip initial whitespace */
while (g_ascii_isspace (value[i]))
i++;
......@@ -1158,13 +1163,14 @@ parse_svg_transform (const gchar *value,
return FALSE;
}
/* ok, have parsed keyword and args, now modify the transform */
/* OK, have parsed keyword and args, now calculate the transform matrix */
if (!strcmp (keyword, "matrix"))
{
if (n_args != 6)
return FALSE;
gimp_matrix3_affine (matrix,
gimp_matrix3_affine (&trafo,
args[0], args[1],
args[2], args[3],
args[4], args[5]);
......@@ -1176,7 +1182,7 @@ parse_svg_transform (const gchar *value,
else if (n_args != 2)
return FALSE;
gimp_matrix3_translate (matrix, args[0], args[1]);
gimp_matrix3_translate (&trafo, args[0], args[1]);
}
else if (!strcmp (keyword, "scale"))
{
......@@ -1185,35 +1191,48 @@ parse_svg_transform (const gchar *value,
else if (n_args != 2)
return FALSE;
gimp_matrix3_scale (matrix, args[0], args[1]);
gimp_matrix3_scale (&trafo, args[0], args[1]);
}
else if (!strcmp (keyword, "rotate"))
{
if (n_args != 1)
if (n_args == 1)
{
gimp_matrix3_rotate (&trafo, gimp_deg_to_rad (args[0]));
}
else if (n_args == 3)
{
gimp_matrix3_translate (&trafo, -args[1], -args[2]);
gimp_matrix3_rotate (&trafo, gimp_deg_to_rad (args[0]));
gimp_matrix3_translate (&trafo, args[1], args[2]);
}
else
return FALSE;
gimp_matrix3_rotate (matrix, gimp_deg_to_rad (args[0]));
}
else if (!strcmp (keyword, "skewX"))
{
if (n_args != 1)
return FALSE;
gimp_matrix3_xshear (matrix, tan (gimp_deg_to_rad (args[0])));
gimp_matrix3_xshear (&trafo, tan (gimp_deg_to_rad (args[0])));
}
else if (!strcmp (keyword, "skewY"))
{
if (n_args != 1)
return FALSE;
gimp_matrix3_yshear (matrix, tan (gimp_deg_to_rad (args[0])));
gimp_matrix3_yshear (&trafo, tan (gimp_deg_to_rad (args[0])));
}
else
{
return FALSE; /* unknown keyword */
}
gimp_matrix3_invert (&trafo);
gimp_matrix3_mult (&trafo, matrix);
}
gimp_matrix3_invert (matrix);
return TRUE;
}
......
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