struct SF::Color
- SF::Color
- Struct
- Value
- Object
Overview
Utility struct for manipulating RGBA colors
SF::Color
is a simple color struct composed of 4 components:
- Red
- Green
- Blue
- Alpha (opacity)
Each component is a public member, an unsigned integer in
the range 0..255
. Thus, colors can be constructed and
manipulated very easily:
color = SF::Color.new(255, 0, 0) # red
color.r = 0 # make it black
color.b = 128 # make it dark blue
The fourth component of colors, named "alpha", represents the opacity of the color. A color with an alpha value of 255 will be fully opaque, while an alpha value of 0 will make a color fully transparent, whatever the value of the other components is.
The most common colors are already defined as static variables:
black = SF::Color::Black
white = SF::Color::White
red = SF::Color::Red
green = SF::Color::Green
blue = SF::Color::Blue
yellow = SF::Color::Yellow
magenta = SF::Color::Magenta
cyan = SF::Color::Cyan
transparent = SF::Color::Transparent
Colors can also be added and modulated (multiplied) using the overloaded operators + and *.
Defined in:
lib/crsfml/src/graphics/graphics.crlib/crsfml/src/graphics/obj.cr
Color/Color.cr