1 /* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 /* Basic constructors and operations for bezier paths */
23 #include "art_bpath.h"
29 * art_bpath_affine_transform: Affine transform an #ArtBpath.
30 * @src: The source #ArtBpath.
31 * @matrix: The affine transform.
33 * Affine transform the bezpath, returning a newly allocated #ArtBpath
34 * (allocated using art_alloc()).
36 * Result (x', y') = (matrix[0] * x + matrix[2] * y + matrix[4],
37 * matrix[1] * x + matrix[3] * y + matrix[5])
39 * Return value: the transformed #ArtBpath.
42 art_bpath_affine_transform (const ArtBpath *src, const double matrix[6])
50 for (i = 0; src[i].code != ART_END; i++);
53 xnew = art_new (ArtBpath, size + 1);
55 for (i = 0; i < size; i++)
59 if (code == ART_CURVETO)
63 xnew[i].x1 = matrix[0] * x + matrix[2] * y + matrix[4];
64 xnew[i].y1 = matrix[1] * x + matrix[3] * y + matrix[5];
67 xnew[i].x2 = matrix[0] * x + matrix[2] * y + matrix[4];
68 xnew[i].y2 = matrix[1] * x + matrix[3] * y + matrix[5];
79 xnew[i].x3 = matrix[0] * x + matrix[2] * y + matrix[4];
80 xnew[i].y3 = matrix[1] * x + matrix[3] * y + matrix[5];
82 xnew[i].code = ART_END;