summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2010-01-19 09:44:30 -0500
committerJeff Muizelaar <jmuizelaar@mozilla.com>2010-01-19 09:44:30 -0500
commitc25ae5202860a53a4a9fb18a20322415fd374235 (patch)
treebb7719f57abeaf9dda9dcc003257f4aef44ab440
parentc8010d7584bd12131aa8d2d9225b55a3d803db5e (diff)
Fix up offseting degenerate splines
-rw-r--r--src/cairo-spline-offset.c90
1 files changed, 54 insertions, 36 deletions
diff --git a/src/cairo-spline-offset.c b/src/cairo-spline-offset.c
index 23a89170..853da4c5 100644
--- a/src/cairo-spline-offset.c
+++ b/src/cairo-spline-offset.c
@@ -13,7 +13,7 @@
#define ISFINITE(x) ((x) * (x) >= 0.) /* check for NaNs */
#endif
-#define printf(a, ...)
+//#define printf(a, ...)
#include "cairoint.h"
#include "cairo-spline-offset.h"
@@ -919,6 +919,9 @@ miter_point_muiz(point_t a, point_t b, point_t c, double width)
static knots_t
knot_offset(knots_t self, double width, cairo_bool_t *is_parallel)
{
+ printf("in: ");
+ print_knot(self);
+ printf("\n");
knots_t result;
double dx0 = self.b.x - self.a.x;
double dy0 = self.b.y - self.a.y;
@@ -935,55 +938,59 @@ knot_offset(knots_t self, double width, cairo_bool_t *is_parallel)
double last_x = 0;
double last_y = 0;
+ double scale;
+
+ scale = 1. / ld0;
+ double dlx0 = -dy0 * scale;
+ double dly0 = dx0 * scale;
+
+ scale = 1. / ld1;
+ double dlx1 = -dy1 * scale;
+ double dly1 = dx1 * scale;
+
+ scale = 1. / ld2;
+ double dlx2 = -dy2 * scale;
+ double dly2 = dx2 * scale;
+
+
if (ld0) {
- last_x = dx0;
- last_y = dy0;
+ last_x = dlx0;
+ last_y = dly0;
}
if (ld1) {
- last_x = dx1;
- last_y = dy1;
+ last_x = dlx1;
+ last_y = dly1;
}
if (ld2) {
- last_x = dx2;
- last_y = dy2;
+ last_x = dlx2;
+ last_y = dly2;
}
if (!ld2) {
- dx2 = last_x;
- dy2 = last_y;
+ printf("not 2\n");
+ dlx2 = last_x;
+ dly2 = last_y;
} else {
- last_x = dx2;
- last_y = dy2;
+ last_x = dlx2;
+ last_y = dly2;
}
if (!ld1) {
- dx1 = last_x;
- dy1 = last_y;
+ printf("not 1\n");
+ dlx1 = last_x;
+ dly1 = last_y;
} else {
- last_x = dx1;
- last_y = dy1;
+ last_x = dlx1;
+ last_y = dly1;
}
if (!ld0) {
- dx0 = last_x;
- dy0 = last_y;
+ printf("not 0\n");
+ dlx0 = last_x;
+ dly0 = last_y;
} else {
- last_x = dx0;
- last_y = dy0;
+ last_x = dlx0;
+ last_y = dly0;
}
- double scale;
-
- scale = 1. / ld0;
- double dlx0 = -dy0 * scale;
- double dly0 = dx0 * scale;
-
- scale = 1. / ld1;
- double dlx1 = -dy1 * scale;
- double dly1 = dx1 * scale;
-
- scale = 1. / ld2;
- double dlx2 = -dy2 * scale;
- double dly2 = dx2 * scale;
-
/* mid-point vector sum */
double dm1x = (dlx0 + dlx1);
double dm1y = (dly0 + dly1);
@@ -1014,8 +1021,11 @@ knot_offset(knots_t self, double width, cairo_bool_t *is_parallel)
result.b.y = self.b.y + dm1y;
result.c.x = self.c.x + dm2x;
result.c.y = self.c.y + dm2y;
- result.d.x = self.d.x + dlx0 * width;
- result.d.y = self.d.y + dly0 * width;
+ result.d.x = self.d.x + dlx2 * width;
+ result.d.y = self.d.y + dly2 * width;
+ printf("out: ");
+ print_knot(result);
+ printf("\n");
return result;
}
@@ -1048,6 +1058,7 @@ knot_offset(knots_t self, double width, cairo_bool_t *is_parallel)
void
curve_offset(knots_t self, double dist, double tolerance, void (*curve_fn)(void *, knots_t), void *closure)
{
+#if 1
point_t n1, n2;
#if 0
self.a.x = 0;
@@ -1137,10 +1148,17 @@ curve_offset(knots_t self, double dist, double tolerance, void (*curve_fn)(void
}
knots_t offset = {{p0p1.x0, p0p1.y0}, n1, n2, {p2p3.x1, p2p3.y1}};
+#endif
+ cairo_bool_t recurse_n;
+ knots_t offset2 = knot_offset(self, dist, &recurse_n);
+ printf("new result: ");
+ print_knot(offset2);
+ recurse = recurse_n;
+ offset = offset2;
// we need to make sure we have a finite offset before checking the error
printf("curve result: ");
- //print_knot(offset);
+ print_knot(offset);
double max_error = 0.01;//500;//0.01;//tolerance;
//double max_error = 0.01;//tolerance;
//bool recurse = !error_within_bounds(self, offset, dist, max_error);