Module: MineSkin::Compositor

Included in:
Preview::Cape2D, Preview::Skin2D
Defined in:
lib/mineskin/compositor.rb

Overview

Composition tools

Instance Method Summary collapse

Instance Method Details

#composite_texture!(tex, x, y, old_unit, op: Magick::SrcOverCompositeOp) ⇒ Object

rubocop:disable MethodLength



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mineskin/compositor.rb', line 9

def composite_texture!(tex, x, y, old_unit, op: Magick::SrcOverCompositeOp)
  @image.composite!(
    resize(tex.texture, old_unit),
    x * @unit,
    y * @unit,
    op
  )
  @image.composite!(
    resize(tex.overlay, old_unit),
    x * @unit,
    y * @unit,
    op
  ) if tex.overlay
end

#resize(img, old_unit) ⇒ Object



4
5
6
# File 'lib/mineskin/compositor.rb', line 4

def resize(img, old_unit)
  img.sample(@unit.to_f / old_unit.to_f)
end