Class: GdkPixbuf::Pixbuf
- Inherits:
-
Object
- Object
- GdkPixbuf::Pixbuf
- Defined in:
- lib/alexandria/ui/icons.rb
Overview
Copyright © 2004-2006 Laurent Sansonetti Copyright © 2014-2016 Matijs van Zuijlen
Alexandria is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Alexandria is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Alexandria; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Instance Method Summary collapse
Instance Method Details
#tag(tag_pixbuf) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/alexandria/ui/icons.rb', line 22 def tag(tag_pixbuf) # Computes some tweaks. tweak_x = tag_pixbuf.width / 3 tweak_y = tag_pixbuf.height / 3 # Creates the destination pixbuf. new_pixbuf = GdkPixbuf::Pixbuf.new(colorspace: :rgb, has_alpha: true, bits_per_sample: 8, width: width + tweak_x, height: height + tweak_y) # Fills with blank. new_pixbuf.fill!(0) # Copies the current pixbuf there (south-west). copy_area(0, 0, width, height, new_pixbuf, 0, tweak_y) # Copies the tag pixbuf there (north-est). tag_pixbuf_x = width - (tweak_x * 2) new_pixbuf.composite!(tag_pixbuf, dest_x: 0, dest_y: 0, dest_width: tag_pixbuf.width + tag_pixbuf_x, dest_height: tag_pixbuf.height, offset_x: tag_pixbuf_x, offset_y: 0, scale_x: 1, scale_y: 1, interpolation_type: :hyper, overall_alpha: 255) new_pixbuf end |