Module: MineSkin::Compositor Private

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Composition tools

Instance Method Summary collapse

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Puts texture to the specified region of @image

Parameters:

  • tex (MineSkin::Texture)

    Texture objet

  • x (Integer)

    X coordinate

  • y (Integer)

    Y coordinate

  • old_unit (Integer)

    Unit size of source image (see #resize)

  • op (Magick::CompositeOperator)

    Operator (optional)



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mineskin/compositor.rb', line 23

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) ⇒ Magick::Image

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Resizes image

Parameters:

  • img (Magick::Image)

    Source image

  • old_unit (Integer)

    Unit size of source image

Returns:

  • (Magick::Image)

    Resized image



10
11
12
# File 'lib/mineskin/compositor.rb', line 10

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