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.
This commit is contained in:
Sven Neumann 2004-08-22 10:50:22 +00:00 committed by Sven Neumann
parent 323e7f4cc0
commit d6a016b4b4
2 changed files with 41 additions and 15 deletions

View File

@ -1,3 +1,10 @@
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

View File

@ -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;
}