struct Glint::Color
- Glint::Color
- Struct
- Value
- Object
Overview
A wrapper for Raylib::Color
.
It provides access to a number of Raylib's color functions.
Always on the look out for more named color palettes!
Defined in:
glint/color.crConstant Summary
-
BEIGE =
Color.new(211, 176, 131, 255)
-
BLACK =
Color.new(0, 0, 0, 255)
-
BLANK =
Color.new(0, 0, 0, 0)
-
BLUE =
Color.new(0, 121, 241, 255)
-
BROWN =
Color.new(127, 106, 79, 255)
-
C64 =
{:black => Color.new(0, 0, 0), :white => Color.new(255, 255, 255), :red => Color.new(136, 0, 0), :cyan => Color.new(170, 255, 238), :violet => Color.new(204, 68, 204), :green => Color.new(0, 204, 85), :blue => Color.new(0, 0, 170), :yellow => Color.new(238, 238, 119), :orange => Color.new(221, 136, 85), :brown => Color.new(102, 68, 0), :light_red => Color.new(255, 119, 119), :grey_1 => Color.new(51, 51, 51), :grey_2 => Color.new(119, 119, 119), :light_green => Color.new(170, 255, 102), :light_blue => Color.new(0, 136, 255), :grey_3 => Color.new(187, 187, 187)}
-
Palette representing the sixteen colours available on the Commodore 64. Source: https://www.c64-wiki.com/wiki/Color
-
COLOR_RANGE =
0..MAXIMUM_VALUE
-
DARKBLUE =
Color.new(0, 82, 172, 255)
-
DARKBROWN =
Color.new(76, 63, 47, 255)
-
DARKGRAY =
Color.new(80, 80, 80, 255)
-
DARKGREEN =
Color.new(0, 117, 44, 255)
-
DARKPURPLE =
Color.new(112, 31, 126, 255)
-
GOLD =
Color.new(255, 203, 0, 255)
-
GRAY =
Color.new(130, 130, 130, 255)
-
GREEN =
Color.new(0, 228, 48, 255)
-
LIGHTGRAY =
Color.new(200, 200, 200, 255)
-
LIME =
Color.new(0, 158, 47, 255)
-
MAGENTA =
Color.new(255, 0, 255, 255)
-
MAROON =
Color.new(190, 33, 55, 255)
-
MAXIMUM_VALUE =
255
-
ONE_BIT =
{:black => Color::BLACK, :white => Color::WHITE}
-
Palette representing the two colours available in a one-bit palette.
-
ORANGE =
Color.new(255, 161, 0, 255)
-
PINK =
Color.new(255, 109, 194, 255)
-
PURPLE =
Color.new(200, 122, 255, 255)
-
RAYLIB_COLORS =
[LIGHTGRAY, GRAY, DARKGRAY, YELLOW, GOLD, ORANGE, PINK, RED, MAROON, GREEN, LIME, DARKGREEN, SKYBLUE, BLUE, DARKBLUE, PURPLE, VIOLET, DARKPURPLE, BEIGE, BROWN, DARKBROWN, WHITE, BLACK, MAGENTA, RAYWHITE, BLANK]
-
RAYWHITE =
Color.new(245, 245, 245, 255)
-
RED =
Color.new(230, 41, 55, 255)
-
SKYBLUE =
Color.new(102, 191, 255, 255)
-
VIOLET =
Color.new(135, 60, 190, 255)
-
WHITE =
Color.new(255, 255, 255, 255)
-
YELLOW =
Color.new(253, 249, 0, 255)
Constructors
-
.new(r : Number, g : Number, b : Number, a : Number = MAXIMUM_VALUE)
Creates a color from an RGB(A) tuple.
-
.new(c : Raylib::Color)
Creates a colour from a
Raylib::Color
. -
.new(hex_color : String)
Creates a colour from a 6- or 8-byte hex string (e.g.
-
.new(value : Number)
Creates a color from a value.
- .new(values : Tuple(Int32, Int32, Int32) | Tuple(Int32, Int32, Int32, Int32))
Class Method Summary
-
.grey(value : Number)
Creates a grey with the specific value.
-
.mix(c1 : Color, c2 : Color)
Mixes a color with another color to make a new color.
-
.random(r_range : Range, g_range : Range, b_range : Range, a_range : Range = COLOR_RANGE)
Creates a random colour with the specified RGB(A)
Range
s. -
.random(transparency : Number = MAXIMUM_VALUE)
Creates a random
Color
from the predefined named colors. -
.random_raylib
Picks a random
Color
from the predefined Raylib colors.
Instance Method Summary
-
#a
Returns the alpha component.
-
#a=(value : Number)
Sets the alpha component.
-
#adjust(&)
Takes a block and adjusts the color in the way(s) defined by the block.
-
#alpha
Returns the color's alpha channel only.
-
#b
Returns the blue component.
-
#b=(value : Number)
Sets the blue component.
-
#blue
Returns the color's blue channel only.
-
#g
Returns the green component.
-
#g=(value : Number)
Sets the green component.
-
#green
Returns the color's green channel only.
-
#mix(other : Color)
Mixes the color with another color to make a new color.
-
#mix!(other : Color)
Changes the color to a mix with with another color.
-
#r
Returns the red component.
-
#r=(value : Number)
Sets the red component.
-
#red
Returns the color's red channel only.
-
#semitransparent!
Sets the alpha value to 127.
-
#semitransparent?
Returns whether the color is semitransparent.
-
#to_hash
Returns the color's values as a
Hash
. - #to_hex
-
#to_s(io : IO)
Returns a string representation of the color.
-
#to_tuple
Returns the color's values as a
Tuple
. -
#to_unsafe : Raylib::Color
Returns the color in a C-compatible format, i.e.
-
#translucent?
Returns whether the color is semitransparent.
-
#transparent!
Sets the alpha value to 0.
-
#transparent?
Returns whether the colour is fully transparent.
-
#values
Returns the color's values as a
Tuple
.
Macro Summary
Constructor Detail
Creates a color from an RGB(A) tuple.
Creates a colour from a 6- or 8-byte hex string (e.g. #ffcc00
or FFCC0080
).
The string can optionally begin with #
(e.g. when using CSS-style colours).
If the alpha component is not specified, it assumes FF
(255) for the alpha
component.
Creates a color from a value.
It could actually be any valid Crystal number, but it probably expects an 8-byte
hex (0xNNNNNNNN
) number.
Class Method Detail
Mixes a color with another color to make a new color.
Creates a random colour with the specified RGB(A) Range
s.
Creates a random Color
from the predefined named colors.
Instance Method Detail
Sets the alpha component.
Returns the Raylib::Color
so it can be changed with #adjust
.
Takes a block and adjusts the color in the way(s) defined by the block.
# Example:
# This takes the predefined `BLACK` colour and makes it semitransparent.
transparent_black = Color::BLACK.adjust { |c| c.a = 127 } # => {255, 255, 255, 127}
Sets the blue component.
Returns the Raylib::Color
so it can be changed with #adjust
.
Sets the green component.
Returns the Raylib::Color
so it can be changed with #adjust
.
Sets the red component.
Returns the Raylib::Color
so it can be changed with #adjust
.
Returns the color in a C-compatible format, i.e. as Raylib::Color
.
This allows for transparent interoperability with the Raylib library.