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 36 foreach (Points p in points) { 37 cr.new_path (); 38 cr.move_to (p.x, p.y); 39 draw_points (cr, p); 40 } 41 42 fill_and_stroke (cr); 43 44 cr.restore (); 45 } 46 47 public void draw_points (Context cr, Points points) { 48 Doubles p = points.point_data; 49 50 return_if_fail (p.size % 6 == 0); 51 52 for (int i = 0; i < p.size; i += 6) { 53 cr.curve_to (p.data[i], p.data[i + 1], 54 p.data[i + 2], p.data[i + 3], 55 p.data[i + 4], p.data[i + 5]); 56 } 57 } 58 59 public override void move (double dx, double dy) { 60 } 61 62 public override void update_region_boundaries () { 63 } 64 65 public override void rotate (double theta, double xc, double yc) { 66 } 67 68 public override bool is_empty () { 69 return false; 70 } 71 72 public override void resize (double ratio_x, double ratio_y) { 73 } 74 75 public override Object copy () { 76 return new SvgPath.create_copy (this); 77 } 78 79 public override string to_string () { 80 return "SvgPath"; 81 } 82 } 83 84 } 85