The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

SvgDrawing.vala in libsvgbird

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 libsvgbird/SvgDrawing.vala.
Move the SVG parser and the SVG rendering code to libsvgbird
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 16 using B; 17 using Cairo; 18 using Math; 19 20 namespace SvgBird { 21 22 public class SvgDrawing : Object { 23 public Layer root_layer = new Layer (); 24 public Defs defs = new Defs (); 25 26 public double x = 0; 27 public double y = 0; 28 public double width = 0; 29 public double height = 0; 30 31 public override void update_region_boundaries () { 32 } 33 34 public override bool is_over (double x, double y) { 35 return (this.x <= x <= this.x + width) 36 && (this.y <= y <= this.y + height); 37 } 38 39 public override void draw (Context cr) { 40 cr.save (); 41 cr.translate (x, y); 42 43 foreach (Object o in root_layer.get_visible_objects ().objects) { 44 o.draw (cr); 45 } 46 47 cr.restore (); 48 } 49 50 public override Object copy () { 51 SvgDrawing drawing = new SvgDrawing (); 52 drawing.root_layer = root_layer.copy (); 53 drawing.defs = defs.copy (); 54 return drawing; 55 } 56 57 public override void move (double dx, double dy) { 58 x += dx; 59 y += dy; 60 } 61 62 public override void rotate (double theta, double xc, double yc) { 63 } 64 65 public override bool is_empty () { 66 return false; 67 } 68 69 public override void resize (double ratio_x, double ratio_y) { 70 } 71 } 72 73 } 74