Clone in a terminal:
Commit b2a7874
Johan Mattsson - 2016-01-10T21:08:35+00:00
b2a78745c9e3ad7e2d182608dc0ad8daf66efa75johan.mattsson.m@gmail.com

SVG line

Changed files (2)

Diff

diff --git a/libsvgbird/Line.vala b/libsvgbird/Line.valanew file mode 100644index 0000000..afbec45--- /dev/null+++ b/libsvgbird/Line.vala@@ -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 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";+	}+}++}diff --git a/libsvgbird/SvgFile.vala b/libsvgbird/SvgFile.valaindex cfaa086..b44a16b 100644--- a/libsvgbird/SvgFile.vala+++ b/libsvgbird/SvgFile.vala@@ -348,9 +348,34 @@ public class SvgFile : GLib.Object { 		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?

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112