The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Calculate orientation for paths with two points.

These changes was commited to the Birdfont repository Sun, 12 Apr 2015 16:55:59 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Apr 2015 16:55:59 +0000 (18:55 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Apr 2015 17:04:57 +0000 (19:04 +0200)
commit cec3b641c258f7dc1a57cf1b7f2ac68d77934655
tree 13c8e03f1faf3282969ac0fae3019c06be114cbf
parent b6592aa9f73a31693346f5b2726a30650bc6b5dd
Calculate orientation for paths with two points.

libbirdfont/Path.vala
libbirdfont/SvgParser.vala
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -657,10 +657,34 @@ public bool is_clockwise () { double s; + Path p; if (unlikely (points.size <= 2)) { no_derived_direction = true; return clockwise_direction; + } + + if (unlikely (points.size == 2)) { + p = copy (); + all_segments ((a, b) => { + double px, py; + double step; + EditPoint new_point; + + step = 0.3; + + Path.get_point_for_step (a, b, step, out px, out py); + + new_point = new EditPoint (px, py); + new_point.prev = a; + new_point.next = b; + + p.insert_new_point_on_path (new_point, step); + + return true; + }); + + return p.is_clockwise (); } s = clockwise_sum (); @@ -2125,7 +2149,7 @@ PathList lines = new PathList (); foreach (Path p in pl.paths) { - lines.add (SvgParser.get_lines (path)); + lines.add (SvgParser.get_lines (p)); } foreach (Path p in lines.paths) {
--- a/libbirdfont/SvgParser.vala +++ b/libbirdfont/SvgParser.vala @@ -540,7 +540,6 @@ public static bool is_inside (EditPoint point, Path path) { EditPoint prev; bool inside = false; - Path lines = path; if (path.points.size <= 1) { return false;