NAME
Graphics::Raylib::Color - Use predefined Raylib colors or define your own
VERSION
version 0.025
SYNOPSIS
use Graphics::Raylib::Color;
my $color = Graphics::Raylib::Color::BLACK;
# alternatively:
use Graphics::Raylib::Color qw(:all);
my $color2 = MAROON;
my $gray = Graphics::Raylib::Color::rgb(127,127,127);
my $rainbow = Graphics::Raylib::Color::rainbow(colors => 100);
push @colors, $rainbow->cycle for (1..100);
DESCRIPTION
Colors you can pass to raylib.
IMPLEMENTATION
As a color is basically a 32-bit integer (RGBA) in raylib, the constructors rgba and rgb do little more packing it into an integer and blessing it. Interpolating a color into a string results in a tuple of the form "(r: %u, g: %u, b: %u, a: %u)"
.
METHODS AND ARGUMENTS
- rgba($red, $green, $blue, $alpha)
-
Constructs a new
Graphics::Raylib::Color
out of 8-bit (0-255) components. - rgb($red, $green, $blue)
-
Constructs a new
Graphics::Raylib::Color
instance out of an opaque color. Callsrgba
with$alpha = 255
. - ($r, $g, $b, $a) = colors
-
Returns a list with the red, green, blue and alpha components of the color.
- rgb($red, $green, $blue)
-
Constructs a new Graphics::Raylib::Color instance out of an opaque color. Calls
rgba
with$alpha = 255
. - color($color_32bit)
-
Constructs a
Color
out of a 32 bit integer. - new($string, [$alpha = 255])
-
Returns a new
Color
that represent the color specified by thestring
. This string should be prefixed by the name of the color space to which it applies. For examplergb:RED,GREEN,BLUE rgb8:RRGGBB rgb16:RRRRGGGGBBBB hsv:HUE,SAT,VAL hsl:HUE,SAT,LUM cmy:CYAN,MAGENTA,YELLOW cmyk:CYAN,MAGENTA,YELLOW,KEY vga:NAME vga:INDEX x11:NAME
This leverages Convert::Color under the hood. Refer to its documentation for more information.
- hsv($hue, $sat, $val, [$alpha = 255])
-
Returns a new
Color
out of HSV components.
PREDEFINED COLORS
use constant LIGHTGRAY => rgb( 200, 200, 200 );
use constant GRAY => rgb( 130, 130, 130 );
use constant DARKGRAY => rgb( 80, 80, 80 );
use constant LIGHTGREY => rgb( 200, 200, 200 );
use constant GREY => rgb( 130, 130, 130 );
use constant DARKGREY => rgb( 80, 80, 80 );
use constant YELLOW => rgb( 253, 249, 0 );
use constant GOLD => rgb( 255, 203, 0 );
use constant ORANGE => rgb( 255, 161, 0 );
use constant PINK => rgb( 255, 109, 194 );
use constant RED => rgb( 230, 41, 55 );
use constant MAROON => rgb( 190, 33, 55 );
use constant GREEN => rgb( 0, 228, 48 );
use constant LIME => rgb( 0, 158, 47 );
use constant DARKGREEN => rgb( 0, 117, 44 );
use constant SKYBLUE => rgb( 102, 191, 255 );
use constant BLUE => rgb( 0, 121, 241 );
use constant DARKBLUE => rgb( 0, 82, 172 );
use constant PURPLE => rgb( 200, 122, 255 );
use constant VIOLET => rgb( 135, 60, 190 );
use constant DARKPURPL => rgb( 112, 31, 126 );
use constant BEIGE => rgb( 211, 176, 131 );
use constant BROWN => rgb( 127, 106, 79 );
use constant DARKBROWN => rgb( 76, 63, 47 );
use constant WHITE => rgb( 255, 255, 255 );
use constant BLACK => rgb( 0, 0, 0 );
use constant BLANK => rgba( 0, 0, 0, 0 );
use constant MAGENTA => rgb( 255, 0, 255 );
use constant RAYWHITE => rgb( 245, 245, 245 );
- rainbow(colors => $color_count)
-
Returns a code reference that cycles through the rainbow colors on each evaluation.
$color_count
is the total number of colors before bouncing back. Default is7
.
GIT REPOSITORY
http://github.com/athreef/Graphics-Raylib
SEE ALSO
AUTHOR
Ahmad Fatoum <athreef@cpan.org>
, http://a3f.at
COPYRIGHT AND LICENSE
Copyright (C) 2017 Ahmad Fatoum
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.