Module: Pixels::HasAlphaChannel
Overview
Mix-in module for image types having an alpha channel.
It makes has_alpha? return true, and it emulates rgb_from_color and color_from_rgb.
Instance Method Summary collapse
-
#color_from_rgb(r, g, b) ⇒ Object
Given separate [r, g, b] values, return the integer colour value.
-
#has_alpha? ⇒ Boolean
Return true of the image has an alpha channel.
-
#rgb_from_color(color) ⇒ Object
Given an integer colour value, return separate [r, g, b] values.
Instance Method Details
#color_from_rgb(r, g, b) ⇒ Object
Given separate [r, g, b] values, return the integer colour value.
This is a wrapper around color_from_rgba. The alpha channel is always set fully opaque.
445 446 447 |
# File 'lib/pixels.rb', line 445 def color_from_rgb(r, g, b) return color_from_rgba(r, g, b, 255) end |
#has_alpha? ⇒ Boolean
Return true of the image has an alpha channel. Otherwise, return false.
430 431 432 |
# File 'lib/pixels.rb', line 430 def has_alpha? true end |
#rgb_from_color(color) ⇒ Object
Given an integer colour value, return separate [r, g, b] values.
This is a wrapper around rgba_from_color. The alpha channel is ignored.
437 438 439 |
# File 'lib/pixels.rb', line 437 def rgb_from_color(color) return rgba_from_color(color)[0..2] end |