Graphi...r::RGB(3pm)
Graphics::Color::RGB π
okay bestie, gather round, because this is the Graphics::Color::RGB page from the User Contributed Perl Documentation section of the perl manual (that's the 3pm part, iykyk) and it's literally just... the RGB color model. iconic behavior. β¨
πΈ NAME πΈ
Graphics::Color::RGB β the RGB color model, bestie. that's it, that's the name.
π VERSION π
version 0.31 π
β¨ SYNOPSIS β¨
here's the whole vibe in one little code block, no cap:
use Graphics::Color::RGB;
my $color = Graphics::Color::RGB->new({
red => 1,
blue => .31,
green => .25,
});
look at her go π¦
π DESCRIPTION π
so Graphics::Color::RGB represents a Color in the sRGB color space. the individual color channels are expressed as decimal values from 0 to 1 β where 0 means a lack of that color (or opaque, in the case of alpha) and 1 means full color (or transparent, in the case of alpha). yes queen, alpha really do be inverted like that. π
and if you don't pass any options at all? then your brand new instance is opaque white, which is exactly equivalent to:
red => 1, green => 1, blue => 1, alpha => 1
slay. default white. main character energy. π€
also there's a whole set of convenience methods supplied to convert this thing into various string values, because sometimes you need your color to be text. it's giving flexible.
π ATTRIBUTES π
red / r
set/get the red component of this Color. also aliased to r, because who has time to type five whole letters. π
green / g
set/get the green component of this Color. also aliased to g. short king. π§
blue / b
set/get the blue component of this Color. also aliased to b. π
alpha / a
set/get the alpha component of this Color. also aliased to a. the transparency girlie. π»
name
get the name of this color. β οΈ heads up though: this is only valid if the color was created by name. no name, no name. periodt.
π METHODS π
as_string
get a string version of this Color, formatted like RED,GREEN,BLUE,ALPHA. π«Ά
as_integer_string
returns an integer formatted value for this color. this format is suitable for CSS RGBA values. cute and CSS-ready. β¨
as_css_hex
returns a hex formatted value with a prepended '#' for use in CSS and HTML. that little hash is doing so much work honestly.
as_hex_string ( [$prepend] )
returns a hex formatted value for this color. π¨
β οΈ important: the output ignores the alpha channel, because per the W3C there is no hexadecimal notation for an RGBA value. so don't come for her about the missing alpha, she's literally following the spec.
optionally, you can pass in a string that will be prepended β and that's the common way people add the "#". π
as_percent_string
returns a percent formatted value for this color. this format is suitable for CSS RGBA values. math but make it fashion. πβ¨
as_array
get the RGB values as an array. π§Ί
as_array_with_alpha
get the RGBA values as an array. extra member, extra flavor. π
equal_to
compares this color to the one you provided. returns 1 if true, otherwise 0. simple. honest. π«‘
not_equal_to
the opposite of equal_to. the hater method, affectionately. π
from_color_library ($color_id)
attempts to retrieve the specified color-id using Color::Library. the result then gets converted into a Graphics::Color::RGB object. glow up complete. π¦
from_hex_string($hex)
attempts to create a Graphics::Color::RGB object from a hex string. works with or without the leading #, and it handles both 3-character and 6-character hex strings. versatile queen. π
to_hsl
creates this RGB color in HSL space. returns a Graphics::Color::HSL object. π
to_hsv
creates this RGB color in HSV space. returns a Graphics::Color::HSV object. π
π AUTHOR π
Cory G Watson <gphat@cpan.org> β shoutout to the author, we stan. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2014 by Cold Hard Code, LLC.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, bestie. ποΈ
and that's the whole page!! π this was perl v5.34.0, dated 2022-06-14, living in the User Contributed Perl Documentation corner of the manual as Graphics::Color::RGB(3pm). go forth and color responsibly, ily, bye!! πβ¨π¦
π¦ where this page comes from
- debian bookworm: libgraphics-color-perl 0.31-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgraphics-color-perl 0.31-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgraphics-color-perl 0.31-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgraphics-color-perl 0.31-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgraphics-color-perl 0.31-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms