The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

BackgroundSelection.vala in libbirdfont

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/BackgroundSelection.vala.
Merge ../birdfont-2.x
1 /* 2 Copyright (C) 2014 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 namespace BirdFont { 16 17 public class BackgroundSelection : GLib.Object { 18 19 public string? assigned_glyph; 20 public BackgroundImage? image; 21 public BackgroundImage parent_image; 22 23 public double x { 24 get { 25 return x_img * parent_image.img_scale_x + parent_image.img_middle_x; 26 } 27 28 set { 29 x_img = (value - parent_image.img_middle_x) / parent_image.img_scale_x; 30 } 31 } 32 33 public double y { 34 get { 35 return y_img * parent_image.img_scale_y + parent_image.img_middle_y; 36 } 37 38 set { 39 y_img = (value - parent_image.img_middle_y) / parent_image.img_scale_y; 40 } 41 } 42 43 public double w { 44 get { 45 return width * parent_image.img_scale_x; 46 } 47 48 set { 49 width = value / parent_image.img_scale_x; 50 } 51 } 52 53 public double h { 54 get { 55 return height * parent_image.img_scale_y; 56 } 57 58 set { 59 height = value / parent_image.img_scale_y; 60 } 61 } 62 63 public double height; 64 public double width; 65 public double x_img; 66 public double y_img; 67 68 public BackgroundSelection (BackgroundImage? img, BackgroundImage parent_img, 69 double x, double y, double w, double h) { 70 71 assigned_glyph = null; 72 parent_image = parent_img; 73 image = img; 74 this.x = x; 75 this.y = y; 76 this.w = w; 77 this.h = h; 78 } 79 80 public BackgroundSelection.absolute (BackgroundImage? img, BackgroundImage parent_img, 81 double x_img, double y_img, double width, double height) { 82 83 assigned_glyph = null; 84 parent_image = parent_img; 85 image = img; 86 this.x_img = x_img; 87 this.y_img = y_img; 88 this.width = width; 89 this.height = height; 90 } 91 } 92 93 } 94