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.
Parse SVG view box
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 width { 27 get { 28 return svg_width; 29 } 30 31 set { 32 svg_width = value; 33 } 34 } 35 36 public double height { 37 get { 38 return svg_height; 39 } 40 41 set { 42 svg_height = value; 43 } 44 } 45 46 public double svg_width = 0; 47 public double svg_height = 0; 48 49 public override bool update_boundaries (Context cr) { 50 apply_transform (cr); 51 root_layer.update_boundaries (cr); 52 53 left = root_layer.left; 54 right = root_layer.right; 55 top = root_layer.top; 56 bottom = root_layer.bottom; 57 58 return true; 59 } 60 61 public override bool is_over (double x, double y) { 62 return false; 63 } 64 65 public void draw (Context cr) { 66 apply_transform (cr); 67 root_layer.draw (cr); 68 } 69 70 public override void draw_outline (Context cr) { 71 root_layer.draw_outline (cr); 72 } 73 74 public override Object copy () { 75 SvgDrawing drawing = new SvgDrawing (); 76 SvgBird.Object.copy_attributes (this, drawing); 77 drawing.root_layer = (Layer) root_layer.copy (); 78 drawing.defs = defs.copy (); 79 drawing.width = width; 80 drawing.height = height; 81 return drawing; 82 } 83 84 public override void move (double dx, double dy) { 85 } 86 87 public override bool is_empty () { 88 return false; 89 } 90 91 public override string to_string () { 92 return @"SvgDrawing width: $width, height: $height"; 93 } 94 } 95 96 } 97