The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Ellipse.vala in libsvgbird

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 libsvgbird/Ellipse.vala.
SVG boundaries for ellipses
1 /* 2 Copyright (C) 2016 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 SvgBird { 19 20 public class Ellipse : Object { 21 22 public double cx = 0; 23 public double cy = 0; 24 public double rx = 0; 25 public double ry = 0; 26 27 public override double left { 28 get { 29 return cx - rx - style.stroke_width / 2; 30 } 31 32 set { 33 } 34 } 35 36 public override double right { 37 get { 38 return cx + rx + style.stroke_width / 2; 39 } 40 41 set { 42 } 43 } 44 45 public override double top { 46 get { 47 return cy - ry - style.stroke_width / 2; 48 } 49 50 set { 51 } 52 } 53 54 public override double bottom { 55 get { 56 return cy + ry + style.stroke_width / 2; 57 } 58 59 set { 60 } 61 } 62 63 public Ellipse () { 64 } 65 66 public override bool is_over (double x, double y) { 67 return false; 68 } 69 70 public override void draw_outline (Context cr) { 71 cr.save (); 72 cr.translate (cx, cy); 73 cr.scale (rx, ry); 74 cr.move_to (1, 0); 75 cr.arc (0, 0, 1, 0, 2 * PI); 76 cr.restore (); 77 } 78 79 public override void move (double dx, double dy) { 80 } 81 82 public override void update_region_boundaries () { 83 } 84 85 public override void rotate (double theta, double xc, double yc) { 86 } 87 88 public override bool is_empty () { 89 return false; 90 } 91 92 public override void resize (double ratio_x, double ratio_y) { 93 } 94 95 public override Object copy () { 96 Ellipse e = new Ellipse (); 97 Object.copy_attributes (this, e); 98 e.cx = cx; 99 e.cy = cy; 100 e.rx = rx; 101 e.ry = ry; 102 return e; 103 } 104 105 public override string to_string () { 106 return "Ellipse"; 107 } 108 } 109 110 } 111