Class: MinecraftAvatars::Face

Inherits:
BaseImage show all
Defined in:
lib/minecraft-avatars/face.rb

Instance Attribute Summary

Attributes inherited from BaseImage

#chunky

Instance Method Summary collapse

Methods inherited from BaseImage

#save, #to_blob, #write

Constructor Details

#initialize(player_name, size = 64) ⇒ Face

Returns a new instance of Face.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/minecraft-avatars/face.rb', line 8

def initialize(player_name, size=64)

  throw InvalidResolutionException unless (size & (size-1)) == 0

  skin = RawSkin.new(player_name)
  self.chunky = ChunkyPNG::Image.new(8, 8, ChunkyPNG::Color::TRANSPARENT)

  self.chunky.compose!(skin.sections[:head_front], 0, 0)
  self.chunky.compose!(skin.sections[:head_accessory], 0, 0)

  self.chunky.resample_nearest_neighbor!(size, size)

end