Class: Gauguin::Image::Pixel
- Inherits:
-
Object
- Object
- Gauguin::Image::Pixel
- Defined in:
- lib/gauguin/image.rb
Constant Summary collapse
- MAX_CHANNEL_VALUE =
257
- MAX_TRANSPARENCY =
65535
Instance Method Summary collapse
-
#initialize(magic_pixel) ⇒ Pixel
constructor
A new instance of Pixel.
- #to_rgb ⇒ Object
- #transparent? ⇒ Boolean
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_rgb ⇒ Object
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
43 44 45 |
# File 'lib/gauguin/image.rb', line 43 def transparent? @magic_pixel.opacity >= MAX_TRANSPARENCY end |