The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Svg circles

These changes was commited to the Birdfont repository Sun, 10 Jan 2016 20:27:07 +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 20:27:07 +0000]

Updated Files

libsvgbird/Circle.vala
libsvgbird/SvgFile.vala
scripts/builder.py
diff --git libsvgbird/Circle.vala(new)
--- /dev/null +++ b/libsvgbird/Circle.vala @@ -1,1 +1,73 @@ + /* + 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"; + } + } + + }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -46,6 +46,10 @@ if (name == "defs") { parse_defs (drawing, t); + } + + if (name == "a") { + parse_link (drawing.root_layer, tag); } parse_object (drawing.root_layer, t); @@ -75,11 +79,15 @@ 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); @@ -201,6 +209,11 @@ if (stop_opacity != null && color != null) { ((!) color).a = parse_number (stop_opacity); } + } + + // 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) { @@ -209,7 +222,7 @@ if (name == "path") { parse_path (layer, tag); } - + if (name == "polygon") { parse_polygon (layer, tag); } @@ -280,11 +293,36 @@ } 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) { }
--- a/scripts/builder.py +++ b/scripts/builder.py @@ -89,7 +89,7 @@ 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 @@ 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 @@ 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)] }