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.
SVG boundaries for ellipses
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 29 public double width { 30 get { 31 return svg_width; 32 } 33 34 set { 35 svg_width = value; 36 } 37 } 38 39 public double height { 40 get { 41 return svg_height; 42 } 43 44 set { 45 svg_height = value; 46 } 47 } 48 49 public double svg_width = 0; 50 public double svg_height = 0; 51 52 public override double left { 53 get { 54 return root_layer.left; 55 } 56 57 set { 58 } 59 } 60 61 public override double right { 62 get { 63 return root_layer.right; 64 } 65 66 set { 67 } 68 } 69 70 public override double top { 71 get { 72 return root_layer.top; 73 } 74 75 set { 76 } 77 } 78 79 public override double bottom { 80 get { 81 return root_layer.bottom; 82 } 83 84 set { 85 } 86 } 87 88 public override void update_region_boundaries () { 89 } 90 91 public override bool is_over (double x, double y) { 92 return (this.x <= x <= this.x + width) 93 && (this.y <= y <= this.y + height); 94 } 95 96 public void draw (Context cr) { 97 root_layer.draw (cr); 98 } 99 100 public override void draw_outline (Context cr) { 101 root_layer.draw_outline (cr); 102 } 103 104 public override Object copy () { 105 SvgDrawing drawing = new SvgDrawing (); 106 SvgBird.Object.copy_attributes (this, drawing); 107 drawing.root_layer = (Layer) root_layer.copy (); 108 drawing.defs = defs.copy (); 109 drawing.x = x; 110 drawing.y = y; 111 drawing.width = width; 112 drawing.height = height; 113 return drawing; 114 } 115 116 public override void move (double dx, double dy) { 117 x += dx; 118 y += dy; 119 } 120 121 public override void rotate (double theta, double xc, double yc) { 122 } 123 124 public override bool is_empty () { 125 return false; 126 } 127 128 public override void resize (double ratio_x, double ratio_y) { 129 } 130 131 public override string to_string () { 132 return @"SvgDrawing x: $x, y: $y, width: $width, height: $height"; 133 } 134 } 135 136 } 137