The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

SVG line

These changes was commited to the Birdfont repository Sun, 10 Jan 2016 21:08:35 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 10 Jan 2016 21:08:35 +0000]

Updated Files

libsvgbird/Line.vala
libsvgbird/SvgFile.vala
diff --git libsvgbird/Line.vala(new)
--- /dev/null +++ b/libsvgbird/Line.vala @@ -1,1 +1,77 @@ + /* + 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 Line : Object { + + public double x1 = 0; + public double y1 = 0; + public double x2 = 0; + public double y2 = 0; + + public Line () { + } + + public Line.create_copy (Line c) { + Object.copy_attributes (c, this); + c.x1 = x1; + c.y1 = y1; + c.x2 = x2; + c.y2 = y2; + } + + public override bool is_over (double x, double y) { + return false; + } + + public override void draw (Context cr) { + cr.save (); + cr.move_to (x1, y1); + cr.line_to (x1, y1); + cr.line_to (x2, y2); + 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 Line.create_copy (this); + } + + public override string to_string () { + return "Line"; + } + } + + }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -348,9 +348,34 @@ layer.add_object (ellipse); } - // FIXME: private void parse_line (Layer layer, Tag tag) { + Line line = new Line (); + + foreach (Attribute attr in tag.get_attributes ()) { + string name = attr.get_name (); + + if (name == "x1") { + line.x1 = parse_number (attr.get_content ()); + } + if (name == "y1") { + line.y1 = parse_number (attr.get_content ()); + } + + if (name == "x2") { + line.x2 = parse_number (attr.get_content ()); + } + + if (name == "y2") { + line.y2 = parse_number (attr.get_content ()); + } + } + + line.transforms = get_transform (tag.get_attributes ()); + line.style = SvgStyle.parse (drawing.defs, tag.get_attributes ()); + line.visible = is_visible (tag); + + layer.add_object (line); } // FIXME: reverse order?