Class: MineSkin::Preview::Skin2D

Inherits:
Object
  • Object
show all
Includes:
Compositor, Unit
Defined in:
lib/mineskin/preview/skin2d.rb

Overview

2D preview of skin

Instance Method Summary collapse

Methods included from Compositor

#composite_texture!, #resize

Methods included from Unit

#image_unit

Constructor Details

#initialize(skin_data) ⇒ Skin2D

Initializes object with skin data

Parameters:



13
14
15
# File 'lib/mineskin/preview/skin2d.rb', line 13

def initialize(skin_data)
  @skin_data = skin_data
end

Instance Method Details

#render(width, background: 'white') ⇒ Magick::Image

Renders preview

Parameters:

  • width

    Width of preview

  • background (String) (defaults to: 'white')

    Optional background color (default white)

Returns:

  • (Magick::Image)

    Preview



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mineskin/preview/skin2d.rb', line 21

def render(width, background: 'white')
  @unit = image_unit size: width, count: 12
  @image = Magick::Image.new(width, 5 * width / 6) do
    self.background_color = background
  end
  render_head!
  render_body!
  render_legs!
  render_arms!
  @image
end