The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Intersection.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/Intersection.vala.
Merge branch '2.10'
1 /* 2 Copyright (C) 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 using Math; 17 18 namespace BirdFont { 19 20 public class Intersection : GLib.Object { 21 public bool done = false; 22 public EditPoint point; 23 public EditPoint other_point; 24 public Path path; 25 public Path other_path; 26 27 public Intersection (EditPoint point, Path path, 28 EditPoint other_point, Path other_path) { 29 30 this.point = point; 31 this.path = path; 32 this.other_point = other_point; 33 this.other_path = other_path; 34 } 35 36 public Intersection.empty () { 37 this.point = new EditPoint (); 38 this.path = new Path (); 39 this.other_point = new EditPoint (); 40 this.other_path = new Path (); 41 } 42 43 public Path get_other_path (Path p) { 44 if (p == path) { 45 return other_path; 46 } 47 48 if (p == other_path) { 49 return path; 50 } 51 52 warning ("Wrong intersection."); 53 return new Path (); 54 } 55 56 public EditPoint get_point (Path p) { 57 if (p == path) { 58 return point; 59 } 60 61 if (p == other_path) { 62 return other_point; 63 } 64 65 warning ("Wrong intersection."); 66 return new EditPoint (); 67 } 68 } 69 70 public class IntersectionList : GLib.Object { 71 public Gee.ArrayList<Intersection> points = new Gee.ArrayList<Intersection> (); 72 73 public IntersectionList () { 74 } 75 76 public Intersection get_point (EditPoint ep, out bool other) { 77 other = false; 78 foreach (Intersection i in points) { 79 if (i.other_point == ep || i.point == ep) { 80 other = (i.other_point == ep); 81 return i; 82 } 83 } 84 85 warning ("No intersection found for point."); 86 return new Intersection.empty (); 87 } 88 } 89 90 } 91