Commit af2a443
SVG ellipse
Changed files (2)
Diff
new file mode 100644@@ -0,0 +1,76 @@+/*+ Copyright (C) 2016 Johan Mattsson++ This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version.++ This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details.+*/++using Cairo;++namespace SvgBird {++public class Ellipse : Object { ++ public double cx = 0;+ public double cy = 0;+ public double rx = 0;+ public double ry = 0;+ + public Ellipse () {+ }++ public Ellipse.create_copy (Ellipse c) {+ Object.copy_attributes (c, this);+ c.cx = cx;+ c.cx = cy;+ c.rx = rx;+ c.ry = ry;+ }+ + public override bool is_over (double x, double y) {+ return false;+ }+ + public override void draw (Context cr) {+ cr.save ();+ cr.translate (cx + rx, cy + ry);+ cr.scale (rx, ry);+ cr.arc (0, 0, 1, 0, 2 * Math.PI);+ apply_transform (cr); + paint (cr);+ cr.restore ();+ }++ public override void move (double dx, double dy) {+ }+ + public override void update_region_boundaries () {+ }++ public override void rotate (double theta, double xc, double yc) {+ }+ + public override bool is_empty () {+ return false;+ }+ + public override void resize (double ratio_x, double ratio_y) {+ }+ + public override Object copy () {+ return new Ellipse.create_copy (this);+ }++ public override string to_string () {+ return "Ellipse";+ }+}++}@@ -315,15 +315,42 @@ public class SvgFile : GLib.Object { circle.style = SvgStyle.parse (drawing.defs, tag.get_attributes ()); circle.visible = is_visible (tag); - layer.add_object (circle); + layer.add_object (circle); } - // FIXME: private void parse_ellipse (Layer layer, Tag tag) {+ Ellipse ellipse = new Ellipse ();+ + foreach (Attribute attr in tag.get_attributes ()) {+ string name = attr.get_name ();+ + if (name == "cx") {+ ellipse.cx = parse_number (attr.get_content ());+ }++ if (name == "cy") {+ ellipse.cy = parse_number (attr.get_content ());+ }+ + if (name == "rx") {+ ellipse.rx = parse_number (attr.get_content ());+ }+ + if (name == "ry") {+ ellipse.ry = parse_number (attr.get_content ());+ }+ }+ + ellipse.transforms = get_transform (tag.get_attributes ());+ ellipse.style = SvgStyle.parse (drawing.defs, tag.get_attributes ());+ ellipse.visible = is_visible (tag); + + layer.add_object (ellipse); } // FIXME: private void parse_line (Layer layer, Tag tag) {+ } // FIXME: reverse order?