summaryrefslogtreecommitdiff
path: root/examples/cairotwisted.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-11-26 18:05:39 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-11-26 18:05:39 +0000
commit0a189cf8c9d4489a30bc1a5f0f4ce62bcc8c9a5d (patch)
tree6e17173786edf5332c51b89ff71e74fdb57c6636 /examples/cairotwisted.c
parent0a557fdd7581a1f9c3ab664b7a594aaa0e61fc68 (diff)
downloadpango-0a189cf8c9d4489a30bc1a5f0f4ce62bcc8c9a5d.tar.gz
Handle close_path correctly.
2008-11-26 Behdad Esfahbod <behdad@gnome.org> * examples/cairotwisted.c (parametrize_path), (point_on_path): Handle close_path correctly. svn path=/trunk/; revision=2745
Diffstat (limited to 'examples/cairotwisted.c')
-rw-r--r--examples/cairotwisted.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/cairotwisted.c b/examples/cairotwisted.c
index e76249da..056377d2 100644
--- a/examples/cairotwisted.c
+++ b/examples/cairotwisted.c
@@ -216,7 +216,7 @@ static parametrization_t *
parametrize_path (cairo_path_t *path)
{
int i;
- cairo_path_data_t *data, current_point;
+ cairo_path_data_t *data, last_move_to, current_point;
parametrization_t *parametrization;
parametrization = malloc (path->num_data * sizeof (parametrization[0]));
@@ -226,8 +226,13 @@ parametrize_path (cairo_path_t *path)
parametrization[i] = 0.0;
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
+ last_move_to = data[1];
current_point = data[1];
break;
+ case CAIRO_PATH_CLOSE_PATH:
+ /* Make it look like it's a line_to to last_move_to */
+ data = (&last_move_to) - 1;
+ /* fall through */
case CAIRO_PATH_LINE_TO:
parametrization[i] = two_points_distance (&current_point, &data[1]);
current_point = data[1];
@@ -245,8 +250,6 @@ parametrize_path (cairo_path_t *path)
current_point = data[3];
break;
- case CAIRO_PATH_CLOSE_PATH:
- break;
default:
g_assert_not_reached ();
}
@@ -320,7 +323,7 @@ point_on_path (parametrized_path_t *param,
{
int i;
double ratio, the_y = *y, the_x = *x, dx, dy;
- cairo_path_data_t *data, current_point;
+ cairo_path_data_t *data, last_move_to, current_point;
cairo_path_t *path = param->path;
parametrization_t *parametrization = param->parametrization;
@@ -333,6 +336,7 @@ point_on_path (parametrized_path_t *param,
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
current_point = data[1];
+ last_move_to = data[1];
break;
case CAIRO_PATH_LINE_TO:
current_point = data[1];
@@ -352,6 +356,10 @@ point_on_path (parametrized_path_t *param,
case CAIRO_PATH_MOVE_TO:
break;
+ case CAIRO_PATH_CLOSE_PATH:
+ /* Make it look like it's a line_to to last_move_to */
+ data = (&last_move_to) - 1;
+ /* fall through */
case CAIRO_PATH_LINE_TO:
{
ratio = the_x / parametrization[i];
@@ -424,8 +432,6 @@ point_on_path (parametrized_path_t *param,
*y += dx * ratio;
}
break;
- case CAIRO_PATH_CLOSE_PATH:
- break;
default:
g_assert_not_reached ();
}