[dia] Bug 604474 - Outline blanking issue with e.g. Hash symbol



commit a532c55da0a14f18b4c5f2e05be8c82a4b2fbf94
Author: Hans Breuer <hans breuer org>
Date:   Sun Dec 13 22:18:53 2009 +0100

    Bug 604474 - Outline blanking issue with e.g. Hash symbol
    
    outline.c : some insignificant off-by-one errors and typos
    geometry.c(line_crosses_ray) : used by distance_bez_shape_point() but did not consistently count. Thus the detection of the point being inside of the given area did not work reliably.

 lib/geometry.c             |   31 +++++++++----------------------
 objects/standard/outline.c |    6 +++---
 2 files changed, 12 insertions(+), 25 deletions(-)
---
diff --git a/lib/geometry.c b/lib/geometry.c
index b6b3a04..8e4b782 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -198,31 +198,18 @@ distance_line_point(const Point *line_start, const Point *line_end,
   return perp_dist;
 }
 
-/* returns 1 iff the line crosses the ray from (-Inf, rayend.y) to rayend */
-static guint
-line_crosses_ray(const Point *line_start, 
+/* returns 1 if the line crosses the ray from (-Inf, rayend.y) to rayend */
+static int
+line_crosses_ray(const Point *line_start,
                  const Point *line_end, const Point *rayend)
 {
-  coord xpos;
-
-  /* swap end points if necessary */
-  if (line_start->y > line_end->y) {
-    const Point *tmp;
-
-    tmp = line_start;
-    line_start = line_end;
-    line_end = tmp;
-  }
-  /* if y coords of line do not include rayend.y */
-  if (line_start->y > rayend->y || line_end->y < rayend->y)
-    return 0;
-  /* Avoid division by zero for horizontal case */
-  if (line_end->y - line_start->y < 0.00000000001) {
-    return (line_end->y - rayend->y < 0.00000000001);
+  if ((line_start->y <= rayend->y && line_end->y > rayend->y) || /* upward crossing */
+      (line_start->y > rayend->y && line_end->y <= rayend->y)) { /* downward crossing */
+    real vt = (rayend->y - line_start->y) / (line_end->y - line_start->y);
+    if (rayend->x < line_start->x + vt * (line_end->x - line_start->x)) /* intersect */
+      return 1;
   }
-  xpos = line_start->x + (rayend->y - line_start->y) * 
-    (line_end->x - line_start->x) / (line_end->y - line_start->y);
-  return xpos <= rayend->x;
+  return 0;
 }
 
 real
diff --git a/objects/standard/outline.c b/objects/standard/outline.c
index 7e3dc31..4ba3e9f 100644
--- a/objects/standard/outline.c
+++ b/objects/standard/outline.c
@@ -393,15 +393,15 @@ outline_draw(Outline *outline, DiaRenderer *renderer)
     int s2 = 0;
     for (i = 1; i < total; ++i) {
       if (BEZ_MOVE_TO == pts[i].type) {
-        /* check wether any point of the second outline is within the first outline. 
+        /* check whether the start point of the second outline is within the first outline. 
 	 * If so it need to be subtracted - currently blanked. */
 	real dist = distance_bez_shape_point (&pts[s1], 
-	  n1 > 0 ? n1 : i - s1 - 1, 0, &pts[i].p1);
+	  n1 > 0 ? n1 : i - s1, 0, &pts[i].p1);
 	if (s2 > s1) { /* blanking the previous one */
 	  n = i - s2 - 1;
           DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s2], n, &color_white);
 	} else { /* fill the outer shape */
-	  n1 = n = i - s1 - 1;
+	  n1 = n = i - s1;
           DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s1], n, &outline->fill_color);
 	}
 	if (dist > 0) { /* remember as new outer outline */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]