Graphi...nstant(3pm)
π Graphics::Toolkit::Color::Constant β access values of color constants π
User Contributed Perl Documentation Β· 3pm
okay bestie, sit down, hydrate, because this one is a whole mood board of named colors and we're gonna go through every single one of them together. no skimming. π
β¨ NAME β¨
Graphics::Toolkit::Color::Constant β access values of color constants
π SYNOPSIS π
use Graphics::Toolkit::Color::Constant qw/:all/;
my @names = Graphics:..:Constant::all_names();
my @rgb = rgb_from_name('darkblue');
my @hsl = hsl_from_name('darkblue');
Graphics::Toolkit::Color::Value::add_rgb('lucky', [0, 100, 50]);
π DESCRIPTION π
so basically, this module hands you the RGB and HSL values of every named color from the X11, HTML(CSS), SVG standard and the Pantone report. it also does nearby search, reverse search, and storage (not permanent, bestie, do not build your whole app on this) of extra names you make up yourself. one color can have multiple names, no cap. π
your own colors can be stored (again: none permanently) for later reference by name. to do that you gotta pick a name that's not already taken. the color itself can be defined by an RGB or HSL triplet.
also important: no symbol is imported by default. the sub symbols rgb_from_name, hsl_from_name, name_from_rgb, name_from_hsl can be imported individually, or all at once with:
use Graphics::Toolkit::Color::Constant qw/:all/;
π ROUTINES π
rgb_from_name
the Red, Green and Blue value of the named color. these values are integers in 0 .. 255. π
my @rgb = Graphics::Toolkit::Color::Constant::rgb_from_name('darkblue');
@rgb = Graphics::Toolkit::Color::Constant::rgb_from_name('dark_blue'); # same result
@rgb = Graphics::Toolkit::Color::Constant::rgb_from_name('DarkBlue'); # still same
hsl_from_name
Hue, saturation and lightness of the named color. these are integers between 0 .. 359 (that's hue) or 100 (that's sat. & light.). a hue of 360 and 0 (degrees in a cylindrical coordinate system) is considered to be the same thing, and this module only deals with the latter. so don't come at it with your 360s. π
my @hsl = Graphics::Toolkit::Color::Constant::hsl_from_name('darkblue');
name_from_rgb
returns the name of the color with the given rgb value triplet. returns an empty string if the color is not stored. when several names define the given color, the shortest name gets selected in scalar context. in array context, you get all the names. π«Ά
say Graphics::Toolkit::Color::Constant::name_from_rgb( 15, 10, 121 ); # 'darkblue'
say Graphics::Toolkit::Color::Constant::name_from_rgb([15, 10, 121]); # works too
name_from_hsl
returns the name of the color with the given hsl value triplet. returns an empty string if the color is not stored. when several names define the given color, the shortest name gets selected in scalar context. in array context, all the names come through. β¨
say scalar Graphics::Toolkit::Color::Constant::name_from_hsl( 0, 100, 50 ); # 'red'
scalar Graphics::Toolkit::Color::Constant::name_from_hsl([0, 100, 50]); # works too
say for Graphics::Toolkit::Color::Constant::name_from_hsl( 0, 100, 50 ); # 'red', 'red1'
names_in_hsl_range
color names in a selected neighbourhood of the hsl color space β the ones that look similar. it takes two arguments. the first one is an array with three values (hue, saturation and lightness) that define the center of the neighbourhood (aka the searched area). π―
the second argument can either be a number or again an array with three values (h, s and l). if it's just a number, that number is the radius r of a ball that defines the neighbourhood. from all the colors inside that ball that are equal distanced or nearer to the center than r, one name gets returned.
if the second argument is an array, it has to contain the tolerance (allowed distance) in h, s and l direction. heads up: the h dimension is circular β the distance from 355 to 0 is 5. the s and l dimensions are linear, so a center value of 90 and a tolerance of 15 results in a search in the range 75 .. 100. π
the results contain only one name per color (the shortest one).
# all bright red'ish clors
my @names = Graphics::Toolkit::Color::Constant::names_in_hsl_range([0, 90, 50], 5);
# approximates to :
my @names = Graphics::Toolkit::Color::Constant::names_in_hsl_range([0, 90, 50],[ 3, 3, 3]);
all_names
a sorted list of all stored color names. πΈ
name_taken
a perlish pseudo boolean that tells you if the color name is already in use. π
add_rgb
adding a color to the store under a not-taken (not already used) name. arguments are name, red, green and blue value (integer < 256, see rgb). π
Graphics::Toolkit::Color::Constant::add_rgb('nightblue', 15, 10, 121 );
Graphics::Toolkit::Color::Constant::add_rgb('nightblue', [15, 10, 121]);
add_hsl
adding a color to the store under a not-taken (not already used) name. arguments are name, hue, saturation and lightness value (see hsl). π¦
Graphics::Toolkit::Color::Constant::add_rgb('lucky', 0, 100, 50 );
Graphics::Toolkit::Color::Constant::add_rgb('lucky', [0, 100, 50]);
π NAMES π
here's the full roster, bestie β every single name in the store. read 'em and weep (affectionately). π
white, black, red, green, blue, yellow, purple, pink, peach, plum, mauve, brown, grey
aliceblue, antiquewhite, antiquewhite1, antiquewhite2, antiquewhite3, antiquewhite4, aqua, aquamarine, aquamarine1, aquamarine2, aquamarine3, aquamarine4, azure, azure1, azure2, azure3, azure4, beige, bisque, bisque1, bisque2, bisque3, bisque4, blanchedalmond, blue1, blue2, blue3, blue4, blueviolet, brown1, brown2, brown3, brown4, burlywood, burlywood1, burlywood2, burlywood3, burlywood4, cadetblue, cadetblue1, cadetblue2, cadetblue3, cadetblue4, chartreuse, chartreuse1, chartreuse2, chartreuse3, chartreuse4, chocolate, chocolate1, chocolate2, chocolate3, chocolate4, coral, coral1, coral2, coral3, coral4, cornflowerblue, cornsilk, cornsilk1, cornsilk2, cornsilk3, cornsilk4, crimson, cyan, cyan1, cyan2, cyan3, cyan4, darkblue, darkcyan, darkgoldenrod, darkgoldenrod1, darkgoldenrod2, darkgoldenrod3, darkgoldenrod4, darkgray, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkolivegreen1, darkolivegreen2, darkolivegreen3, darkolivegreen4, darkorange, darkorange1, darkorange2, darkorange3, darkorange4, darkorchid, darkorchid1, darkorchid2, darkorchid3, darkorchid4, darkred, darksalmon, darkseagreen, darkseagreen1, darkseagreen2, darkseagreen3, darkseagreen4, darkslateblue, darkslategray, darkslategray1, darkslategray2, darkslategray3, darkslategray4, darkturquoise, darkviolet, deeppink, deeppink1, deeppink2, deeppink3, deeppink4, deepskyblue, deepskyblue1, deepskyblue2, deepskyblue3, deepskyblue4, dimgray, dodgerblue, dodgerblue1, dodgerblue2, dodgerblue3, dodgerblue4, firebrick, firebrick1, firebrick2, firebrick3, firebrick4, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, gold1, gold2, gold3, gold4, goldenrod, goldenrod1, goldenrod2, goldenrod3, goldenrod4, gray, gray1, gray2, gray3, gray4, gray5, gray6, gray7, gray8, gray9, gray10, gray11, gray12, gray13, gray14, gray15, gray16, gray17, gray18, gray19, gray20, gray21, gray22, gray23, gray24, gray25, gray26, gray27, gray28, gray29, gray30, gray31, gray32, gray33, gray34, gray35, gray36, gray37, gray38, gray39, gray40, gray41, gray42, gray43, gray44, gray45, gray46, gray47, gray48, gray49, gray50, gray51, gray52, gray53, gray54, gray55, gray56, gray57, gray58, gray59, gray60, gray61, gray62, gray63, gray64, gray65, gray66, gray67, gay68, gray69, gray70, gray71, gray72, gray73, gray74, gray75, gray76, gray77, gray78, gray79, gray80, gray81, gray82, gray83, gray84, gray85, gray86, gray87, gray88, gray89, gray90, gray91, gray92, gray93, gray94, gray95, gray97, gray98, gray99, green1, green2, green3, green4, greenyellow, grey1, grey2, grey3, grey4, honeydew, honeydew1, honeydew2, honeydew3, honeydew4, hotpink, hotpink1, hotpink2, hotpink3, hotpink4, indianred, indianred1, indianred2, indianred3, indianred4, indigo, ivory, ivory1, ivory2, ivory3, ivory4, khaki, khaki1, khaki2, khaki3, khaki4, lavender, lavenderblush, lavenderblush1, lavenderblush2, lavenderblush3, lavenderblush4, lawngreen, lemonchiffon, lemonchiffon1, lemonchiffon2, lemonchiffon3, lemonchiffon4, light, lightblue, lightblue1, lightblue2, lightblue3, lightblue4, lightcoral, lightcyan, lightcyan1, lightcyan2, lightcyan3, lightcyan4, lightgoldenrod, lightgoldenrod1, lightgoldenrod2, lightgoldenrod3, lightgoldenrod4, lightgray, lightgreen, lightpink, lightpink1, lightpink2, lightpink3, lightpink4, lightpurple, lightsalmon, lightsalmon1, lightsalmon2, lightsalmon3, lightsalmon4, lightseagreen, lightskyblue, lightskyblue1, lightskyblue2, lightskyblue3, lightskyblue4, lightslateblue, lightslategray, lightsteelblue, lightsteelblue1, lightsteelblue2, lightsteelblue3, lightsteelblue4, lightyellow, lightyellow1, lightyellow2, lightyellow3, lightyellow4, lime, limegreen, linen, magenta, magenta1, magenta2, magenta3, magenta4, maroon, maroon1, maroon2, maroon3, maroon4, medium, mediumaquamarine, mediumblue, mediumorchid, mediumorchid1, mediumorchid2, mediumorchid3, mediumorchid4, mediumpurple, mediumpurple1, mediumpurple2, mediumpurple3, mediumpurple4, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, mistyrose1, mistyrose2, mistyrose3, mistyrose4, moccasin, navajowhite, navajowhite1, navajowhite2, navajowhite3, navajowhite4, navy, navyblue, oldlace, olive, olivedrab, olivedrab1, olivedrab2, olivedrab3, olivedrab4, orange, orange1, orange2, orange3, orange4, orangered, orangered1, orangered2, orangered3, orangered4, orchid, orchid1, orchid2, orchid3, orchid4, pale, palegoldenrod, palegreen, palegreen1, palegreen2, palegreen3, palegreen4, paleturquoise, paleturquoise1, paleturquoise2, paleturquoise3, paleturquoise4, palevioletred, palevioletred1, palevioletred2, palevioletred3, palevioletred4, papayawhip, peachpuff, peachpuff1, peachpuff2, peachpuff3, peachpuff4, peru, pink1, pink2, pink3, pink4, plum1, plum2, plum3, plum4, powderblue, purple1, purple2, purple3, purple4, rebeccapurple, red1, red2, red3, red4, rosybrown, rosybrown1, rosybrown2, rosybrown3, rosybrown4, royalblue, royalblue1, royalblue2, royalblue3, royalblue4, saddlebrown, salmon, salmon1, salmon2, salmon3, salmon4, sandybrown, seagreen, seagreen1, seagreen2, seagreen3, seagreen4, seashell, seashell1, seashell2, seashell3, seashell4, sienna, sienna1, sienna2, sienna3, sienna4, silver, skyblue, skyblue1, skyblue2, skyblue3, skyblue4, slateblue, slateblue1, slateblue2, slateblue3, slateblue4, slategray, slategray1, slategray2, slategray3, slategray4, snow, snow1, snow2, snow3, snow4, springgreen, springgreen1, springgreen2, springgreen3, springgreen4, steelblue, steelblue1, steelblue2, steelblue3, steelblue4, tan, tan1, tan2, tan3, tan4, teal, thistle, thistle1, thistle2, thistle3, thistle4, tomato, tomato1, tomato2, tomato3, tomato4, turquoise, turquoise1, turquoise2, turquoise3, turquoise4, violet, violetred, violetred1, violetred2, violetred3, violetred4, wheat, wheat1, wheat2, wheat3, wheat4, whitesmoke, yellow1, yellow2, yellow3, yellow4, yellowgreen
...and the color rollout keeps going, bestie, because this list does not stop and honestly? iconic π every single one of these is a real entry, spelled exactly like this, so don't you dare "fix" the typos, they're load-bearing:
marsalaradiandorchidemeraldtangerinetangohoneysucleturquoisemimosablueizischilipeppersanddollarblueturquoisetigerlilyaquaskytrueredfuchsiaroseceruleanbluerosequartzpeachechoserenitysnorkelbluelimpetshelllilacgreyicedcoffeefiestabuttercupgreenflashriversideairybluesharkskinauroraredwarmtaupedustycedarlushmeadowspicymustardpottersclaybodaciousgreeneryniagaraprimroseyellowlapisblueflameislandparadisepaledogwoodpinkyarrowkalehazelnutgrenadineballetslipperbutterumnavypeonyneutralgrayshadedsprucegoldenlimemarinaautumnmaplemeadowlarkcherrytomatolittleboybluechilioilpinklavenderbloomingdahliaarcadiaultravioletemperadoralmostmauvespringcrocussailorblueharbormistwarmsandcoconutmilkredpearvaliantpoppynebulasblueceylonyellowmartinioliverussetorangecrocuspetallimelightquetzalgreensargassoseatofualmondbuffquietgraymeerkatfiestajesterredturmericlivingcoralpinkpeacockpepperstemaspengoldprincessbluetoffeemangomojitoterrariummosssweetlilacsoybeaneclipsesweetcornbrowngranitechilipepperbikingredpeachpinkrockyroadfruitdovesugaralmonddarkcheddargalaxybluebluestoneorangetigeredenvanillacustardeveningbluepalomaguacamoleflamescarletsaffronbiscaygreenchivefadeddenimorangepeelmosaicbluesunlightcoralpinkgrapecompotelarknavyblazerbrilliantwhiteashamberglowsambasandstoneclassicbluegreensheenrosetanultramarinegreenfiredbrickpeachnougatmagentapurplemarigoldceruleanrustilluminatingfrenchbluegreenashburntcoralmintamethystorchidraspberrysorbetinkwellultimategraybuttercreamdesertmistwillow
ngl bestie, yes,fiestaandchilipeppershow up twice in that rollout. that's not a typo on my part, that's the list being the list. leave it alone, it's serving chaos π
π¦ SEE ALSO
Graphics::ColorNamesLite::Allβ the whole color-names library, if you want the entire buffet and not just this snack pack π
π COPYRIGHT & LICENSE
Copyright 2022 Herbert Breunung.
This program is free software; you can redistribute it and/or modify it under same terms as Perl itself. fr fr, same vibe as Perl, no extra drama β¨
π AUTHOR
Herbert Breunung, <lichtkind@cpan.org>
and that's a wrap on part 2, bestie π«Ά this page came from the perl v5.36.0 docs, dated 2023-01-30, and it's the Graphi...nstant(3pm) manual β go forth and color your world, you absolute main character ππ
π¦ where this page comes from
- debian bookworm: libgraphics-toolkit-color-perl 1.08-1 Β· 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