changeset 520:81481e59e195

Almost working.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 06 Feb 2007 02:33:03 +0000
parents 173e37b1c291
children e7efe3a186da
files src/xs_curve.c
diffstat 1 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_curve.c	Tue Feb 06 02:33:01 2007 +0000
+++ b/src/xs_curve.c	Tue Feb 06 02:33:03 2007 +0000
@@ -220,50 +220,69 @@
 			i * (width / 4.0) + RADIUS, height + RADIUS);
 	}
 
-	
+
+#if 1
 	/* Draw the spline/curve itself */
 	p0 = curve->ctlpoints;
-	p1 = p0; p1++;
+	p1 = p0;
 	p2 = p1; p2++;
 	p3 = p2; p3++;
 
 	/* Draw each curve segment */
-	fprintf(stderr, "npoints = %d\n", curve->num_ctlpoints);
+	fprintf(stderr, "-- npoints = %d\n", curve->num_ctlpoints);
+	if (curve->num_ctlpoints > 5)
 	for (i = 0; i < curve->num_ctlpoints; i++, ++p0, ++p1, ++p2, ++p3) {
 		gfloat k1, k2, a, b, c, d, x;
-
+fprintf(stderr, "#%d: ", i);
 		if (p1->x == p2->x)
 			continue;
+#define PPASK(q, p) fprintf(stderr, q "=[%1.3f, %1.3f]  ", p->x, p->y)
 
+		PPASK("p0", p1);
+		PPASK("p1", p1);
+		PPASK("p2", p2);
+		PPASK("p3", p3);
+		
+		fprintf(stderr, "\ncase #");
 		if (p0->x == p1->x && p2->x == p3->x) {
+			fprintf(stderr, "1");
 			k1 = k2 = (p2->y - p1->y) / (p2->x - p1->x);
 		} else if (p0->x == p1->x) {
+			fprintf(stderr, "2");
 			k2 = (p3->y - p1->y) / (p3->x - p1->x);
 			k1 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k2) / 2;
 		} else if (p2->x == p3->x) {
+			fprintf(stderr, "3");
 			k1 = (p2->y - p0->y) / (p2->x - p0->x);
 			k2 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k1) / 2;
 		} else {
+			fprintf(stderr, "4");
 			k1 = (p2->y - p0->y) / (p2->x - p0->x);
 			k2 = (p3->y - p1->y) / (p3->x - p1->x);
 		}
 
 		xs_cubic_coeff(p1->x, p1->y, p2->x, p2->y, k1, k2, &a, &b, &c, &d);
-		fprintf(stderr, "--seg[%1.3f, %1.3f]=>[%1.3f, %1.3f]--\n", p1->x, p1->y, p2->x, p2->y);
+		fprintf(stderr, " seg[%1.3f, %1.3f] => [%1.3f, %1.3f] k1=%1.3f, k2=%1.3f\n\n",
+			p1->x, p1->y,
+			p2->x, p2->y,
+			k1, k2);
+#if 1
 		for (x = p1->x; x <= p2->x; x += res) {
 			gfloat y = ((a * x + b) * x + c) * x + d;
 			gint qx, qy;
 			qx = RADIUS + xs_project(x, curve->min_x, curve->max_x, width);
 			qy = RADIUS + xs_project(y, curve->min_y, curve->max_y, height);
-			fprintf(stderr, "[%1.3f, %1.3f] -> %d, %d\n", x, y, qx, qy);
+
 			gdk_draw_point(curve->pixmap, style->fg_gc[state],
 				RADIUS + xs_project(x, curve->min_x, curve->max_x, width),
 				RADIUS + xs_project(y, curve->min_y, curve->max_y, height));
 
 		}
-		fprintf(stderr, "-------\n");
+#endif
 	}
-	
+	fprintf(stderr, "-------\n");
+#endif
+
 	/* Draw control points */
 	for (i = 0; i < curve->num_ctlpoints; ++i) {
 		gint x, y;