Class: Gauguin::Image::Pixel

Inherits:
Object
  • Object
show all
Defined in:
lib/gauguin/image.rb

Constant Summary collapse

MAX_CHANNEL_VALUE =
257
MAX_TRANSPARENCY =
65535

Instance Method Summary collapse

Constructor Details

#initialize(magic_pixel) ⇒ Pixel

Returns a new instance of Pixel.



39
40
41
# File 'lib/gauguin/image.rb', line 39

def initialize(magic_pixel)
  @magic_pixel = magic_pixel
end

Instance Method Details

#to_rgbObject



47
48
49
50
51
# File 'lib/gauguin/image.rb', line 47

def to_rgb
  [:red, :green, :blue].map do |color|
    @magic_pixel.send(color) / MAX_CHANNEL_VALUE
  end
end

#transparent?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/gauguin/image.rb', line 43

def transparent?
  @magic_pixel.opacity >= MAX_TRANSPARENCY
end