Commit d3667a0
Svg circles
Changed files (3)
Diff
new file mode 100644@@ -0,0 +1,72 @@+/*+ 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 Circle : Object { ++ public double cx = 0;+ public double cy = 0;+ public double r = 0;+ + public Circle () {+ }++ public Circle.create_copy (Circle c) {+ Object.copy_attributes (c, this);+ c.cx = cx;+ c.cx = cy;+ c.r = r;+ }+ + public override bool is_over (double x, double y) {+ return false;+ }+ + public override void draw (Context cr) {+ cr.save ();+ cr.arc (cx, cy, r, 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 Circle.create_copy (this);+ }++ public override string to_string () {+ return "Circle";+ }+}++}@@ -48,6 +48,10 @@ public class SvgFile : GLib.Object { parse_defs (drawing, t); } + if (name == "a") {+ parse_link (drawing.root_layer, tag);+ }+ parse_object (drawing.root_layer, t); } @@ -75,12 +79,16 @@ public class SvgFile : GLib.Object { foreach (Tag t in tag) { string name = t.get_name ();- + if (name == "g") { Layer sublayer = new Layer (); parse_layer (layer, t); layer.subgroups.add (sublayer); }++ if (name == "a") {+ parse_link (layer, t);+ } parse_object (layer, t); }@@ -203,13 +211,18 @@ public class SvgFile : GLib.Object { } } + // links are ignored, add the content to the layer+ void parse_link (Layer layer, Tag tag) {+ parse_layer (layer, tag);+ }+ void parse_object (Layer layer, Tag tag) { string name = tag.get_name (); if (name == "path") { parse_path (layer, tag); }- + if (name == "polygon") { parse_polygon (layer, tag); }@@ -280,11 +293,36 @@ public class SvgFile : GLib.Object { } private void parse_circle (Layer layer, Tag tag) {+ Circle circle = new Circle ();+ + foreach (Attribute attr in tag.get_attributes ()) {+ string name = attr.get_name ();+ + if (name == "cx") {+ circle.cx = parse_number (attr.get_content ());+ }++ if (name == "cy") {+ circle.cy = parse_number (attr.get_content ());+ }+ + if (name == "r") {+ circle.r = parse_number (attr.get_content ());+ }+ }+ + circle.transforms = get_transform (tag.get_attributes ());+ circle.style = SvgStyle.parse (drawing.defs, tag.get_attributes ());+ circle.visible = is_visible (tag); + + layer.add_object (circle); } + // FIXME: private void parse_ellipse (Layer layer, Tag tag) { } + // FIXME: private void parse_line (Layer layer, Tag tag) { } @@ -89,7 +89,7 @@ class Builder(object): yield { 'basename': 'valac ' + source_directory,- 'file_dep': [build_file] + vala_source_paths + bindep,+ 'file_dep': [build_file] + vala_source_paths, 'actions': [valac_command], 'targets': generated_csource_paths }@@ -106,7 +106,7 @@ class Builder(object): command = command.replace('OBJECT_FILE', object_path) yield { 'basename': 'compile ' + csource,- 'file_dep': [build_file, csource] + bindep + copied_cheader,+ 'file_dep': [build_file, csource] + copied_cheader, 'actions': [command], 'targets': [path.join(build_directory, object_file)], }@@ -114,7 +114,7 @@ class Builder(object): object_paths = [path.join(build_directory, f) for f in object_files] yield { 'basename': source_directory,- 'file_dep': object_paths + [build_file] + bindep,+ 'file_dep': object_paths + [build_file], 'actions': [linker_command], 'targets': [path.join('build', 'bin', target_binary)] }