Module: MineSkin::Extractor
Instance Method Summary collapse
-
#crop(texture) ⇒ Magick::Image
Extracts texture.
-
#extract(hash) ⇒ MineSkin::Cuboid
Constructs a Cuboid from given regions.
-
#part(texture: { x: 0, y: 0, width: 0, height: 0 }, overlay: nil) ⇒ MineSkin::Texture
Constructs a Texture object from given regions.
Instance Method Details
#crop(texture) ⇒ Magick::Image
Extracts texture
8 9 10 11 12 13 14 15 |
# File 'lib/mineskin/extractor.rb', line 8 def crop(texture) @image.crop( texture[:x] * @unit, texture[:y] * @unit, texture[:width] * @unit, texture[:height] * @unit ) end |
#extract(hash) ⇒ MineSkin::Cuboid
Constructs a Cuboid from given regions
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mineskin/extractor.rb', line 36 def extract(hash) Cuboid.new( part(hash[:top]), part(hash[:bottom]), part(hash[:left]), part(hash[:right]), part(hash[:front]), part(hash[:back]) ) end |
#part(texture: { x: 0, y: 0, width: 0, height: 0 }, overlay: nil) ⇒ MineSkin::Texture
Constructs a Texture object from given regions
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mineskin/extractor.rb', line 21 def part(texture: { x: 0, y: 0, width: 0, height: 0 }, overlay: nil) tex = crop coords_to_h texture part = Texture.new(tex, nil) if over = crop coords_to_h part. = over end part end |