Class: RubySprites::GraphicsManager::Gd2
- Inherits:
-
RubySprites::GraphicsManager
- Object
- RubySprites::GraphicsManager
- RubySprites::GraphicsManager::Gd2
- Defined in:
- lib/lash-sprites/graphics_manager/gd2.rb
Constant Summary collapse
- DESCRIPTION =
'GD2'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.availible? ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/lash-sprites/graphics_manager/gd2.rb', line 9 def self.availible? begin require 'rubygems' require 'gd2' rescue LoadError return false end return true end |
Instance Method Details
#combine(images, width, height) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lash-sprites/graphics_manager/gd2.rb', line 20 def combine(images, width, height) image = GD2::Image.new(width, height) images.each do |path, img| next unless img.exists? i = GD2::Image.import(@sprite.file_root + path) w = width - img.x w = img.width if img.width < w h = height - img.y h = img.height if img.height < h image.copy_from(i, img.x, img.y, 0, 0, w, h) i = nil end image.export(@sprite.image_file) end |
#get_info(path) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/lash-sprites/graphics_manager/gd2.rb', line 35 def get_info(path) img = GD2::Image.import(@sprite.file_root + path) info = {:width => img.width, :height => img.height} img = nil return info end |