Class | GD2::Color |
In: |
lib/gd2/color.rb
|
Parent: | Object |
Color objects hold the red, green, blue, and alpha components for a pixel color. Color objects may also be linked to a particular palette index associated with an image.
Color objects are created by specifying the individual components:
red = Color[1.0, 0.0, 0.0] green = Color[0.0, 1.0, 0.0] blue = Color[0.0, 0.0, 1.0] transparent_yellow = Color[1.0, 1.0, 0.0, 0.5]
The components may be specified as a percentage, as an explicit value between 0..RGB_MAX or 0..ALPHA_MAX, or as another color from which the associated component will be extracted.
BLACK | = | Color[0.0, 0.0, 0.0].freeze |
WHITE | = | Color[1.0, 1.0, 1.0].freeze |
TRANSPARENT | = | Color[0.0, 0.0, 0.0, ALPHA_TRANSPARENT].freeze |
rgba | -> | to_i |
new | -> | [] |
index | [R] | The palette index of this color, if associated with an image palette |
palette | [R] | The palette of this color, if associated with an image palette |
Like Color#alpha_blend! except returns a new Color without modifying the receiver.
Alpha blend this color with the given color. If this color is associated with a palette entry, this also modifies the palette.
Compare this color with another color in a manner that takes into account palette identities.
Return true if this color is associated with the specified palette, or with any palette if nil is given.