The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Merge self intersections

These changes was commited to the Birdfont repository Wed, 12 Aug 2015 08:27:46 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Wed, 12 Aug 2015 08:27:46 +0000]

Updated Files

libbirdfont/EditPoint.vala
libbirdfont/StrokeTool.vala
--- a/libbirdfont/EditPoint.vala +++ b/libbirdfont/EditPoint.vala @@ -57,6 +57,7 @@ public static uint SEGMENT_END = 1 << 14; public static uint SPLIT_POINT = 1 << 15; public static uint SELF_INTERSECTION = 1 << 16; + public static uint COPIED_SELF_INTERSECTION = 1 << 17; public static uint ALL = 0xFFFFFF;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -495,7 +495,7 @@ } } - // reset copied points + // reset copy flag foreach (EditPoint n in path1.points) { n.flags &= uint.MAX ^ EditPoint.COPIED; } @@ -609,14 +609,12 @@ bool other; print (@"SELF_INTERSECTION: $(ep1.x), $(ep1.y)\n"); new_start = intersections.get_point (ep1, out other); - i = index_of (current, other ? new_start.point : new_start.other_point); - if (self_intersection_point == new_start) { - print ("Done self intersection\n"); - break; - } + print (@"from $i "); - self_intersection_point = new_start; + i = index_of (current, other ? new_start.point : new_start.other_point); + + print (@"start at $i\n"); if (!(0 <= i < current.points.size)) { warning (@"Index out of bounds. ($i)"); @@ -624,7 +622,21 @@ } ep1 = current.points.get (i); - } else if ((ep1.flags & EditPoint.COPIED) > 0) { + + // take the other point if it already is copied + if ((ep1.flags & EditPoint.COPIED) > 0) { + i = index_of (current, !other ? new_start.point : new_start.other_point); + + if (!(0 <= i < current.points.size)) { + warning (@"Index out of bounds. ($i)"); + return r; + } + + ep1 = current.points.get (i); + } + } + + if ((ep1.flags & EditPoint.COPIED) > 0) { new_path.close (); EditPoint first_point = new_path.get_first_point (); EditPointHandle h; @@ -637,7 +649,18 @@ } } - break; + // self intersections will be copied twice + if ((ep1.flags & EditPoint.SELF_INTERSECTION) > 0) { + if ((ep1.flags & EditPoint.COPIED_SELF_INTERSECTION) == 0) { + ep1.flags |= EditPoint.COPIED_SELF_INTERSECTION; + } else { + print (@"DONE SELF_INTERSECTION $(ep1.x), $(ep1.y)\n"); + break; + } + } else { + print (@"DONE COPIED $(ep1.x), $(ep1.y)\n"); + break; + } } // adjust the other handle @@ -654,6 +677,8 @@ new_path.get_last_point ().left_handle.move_to_coordinate (previous.left_handle.x, previous.left_handle.y); } + print (@"Add point $(ep1.x), $(ep1.y)\n"); + i++; ep1 = current.points.get (i % current.points.size); }