The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

SvgPath.vala in libbirdfont/Svg

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/Svg/SvgPath.vala.
Use SVG transform, parse opacity and gradients
1 /* 2 Copyright (C) 2016 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 17 namespace BirdFont { 18 19 public class SvgPath : Object { 20 public Gee.ArrayList<Points> points = new Gee.ArrayList<Points> (); 21 22 public SvgPath () { 23 } 24 25 public SvgPath.create_copy (SvgPath p) { 26 Object.copy_attributes (p, this); 27 } 28 29 public override bool is_over (double x, double y) { 30 return false; 31 } 32 33 public override void draw (Context cr, Color? c = null) { 34 cr.save (); 35 apply_transform (cr); 36 cr.new_path (); 37 38 foreach (Points p in points) { 39 cr.move_to (p.x, p.y); 40 draw_points (cr, p); 41 42 if (p.closed) { 43 cr.close_path (); 44 } 45 } 46 47 fill_and_stroke (cr); 48 cr.restore (); 49 } 50 51 public void draw_points (Context cr, Points points) { 52 Doubles p = points.point_data; 53 54 return_if_fail (p.size % 6 == 0); 55 56 for (int i = 0; i < p.size; i += 6) { 57 cr.curve_to (p.data[i], p.data[i + 1], 58 p.data[i + 2], p.data[i + 3], 59 p.data[i + 4], p.data[i + 5]); 60 } 61 } 62 63 public override void move (double dx, double dy) { 64 } 65 66 public override void update_region_boundaries () { 67 } 68 69 public override void rotate (double theta, double xc, double yc) { 70 } 71 72 public override bool is_empty () { 73 return false; 74 } 75 76 public override void resize (double ratio_x, double ratio_y) { 77 } 78 79 public override Object copy () { 80 return new SvgPath.create_copy (this); 81 } 82 83 public override string to_string () { 84 return "SvgPath"; 85 } 86 } 87 88 } 89