Graphic...ual::Set(3)
๐จ NAME
Graphics::Toolkit::Color::Manual::Set โ the reference page for all the color set creation methods, bestie. It's giving "everything you need to know to build color families" energy. ๐
Oh and real quick โ this lives in the User Contributed Perl Documentation section of the manual, page Graphic...ual::Set(3). Now let's go. โจ
โจ SYNOPSIS โจ
Okay so this page is the most detailed description of the four color set creation methods ever, no cap:
complementanalogousgradientcluster
Plus a full explanation of every argument they take. ๐ซถ
Every single one of these methods returns a list of GTC objects โ unless, bestie, a typo or a data type mismatch happens, in which case you get an error. ๐ Periodt.
๐ METHODS ๐
๐ complement ๐
complement computes complementary colors (GTC objects). These are colors that are exactly as colorful (saturated) and bright (lightness) as the original color โ that's the invocant, btw โ but their hue differs in a way that's optimized for contrast. Iconic.
The method accepts five named and optional arguments: steps, in, target, tilt and skew. The last three extend the described concept greatly โ like, they really take it there. ๐ฅ
If you pass no argument at all, you get THE single complementary color, which has the opposite hue of the original. So simple, so slay. And steps is the one you can use as the only positional argument if you're feeling lazy. ๐
stepsโ prescribes the amount of colors produced. Has to be a positive integer, and it defaults to one. Sincecomplementworks only in cylindrical spaces of the HSL family, imagine a horizontal circle in HSL space around the middle column.complementsimply divides this circle into equally sized slices, and every point where the circle is cut becomes a complementary color. The color (point) on the opposite side of the original color is THE complement. If you choose two steps (cut the circle in two) you get THE complementary and the original; with three steps you get triadic colors; with four you get tetradic (quadratic) colors, and so forth. For values greater than one, the invocant will always be the last color returned. ๐inโ sets the color space thecomplementwill be computed in, which is OKHSL per default. It has to be a space of the HSL family. ๐ฆtargetโ moves THE complement, and thus the whole circle of complementary colors. Only the given color stays unaltered and part of the circle. The argument expects a HASH reference which contains some or all axis names (short or long) of the chosen color space (the argumentin). The values associated with the axis names will be added to the values of THE complement (the target color) the same wayadd_valuewould do. ๐ฏtiltโ moves the colors along the described circle of complements. The expected floating point number describes how much they're moved toward THE complement (target) if positive, and toward the original color if negative. What's traditionally meant by split-complementary colors? You get that with atiltfactor of around 3.42 with threesteps, or 1.585 with foursteps(depending on whether you need THE complement in your set).tiltdefaults to zero. ๐ธskewโ rotates the circle of complementary colors around the axis that pierces through the original color and THE complement. This results in stronger differences of lightness between the complementary colors.skewexpects a floating point number. If that's positive, the right side of the circle (looking toward THE complement) is moved up (toward white), and vice versa.skewdefaults to zero. โญ
Real talk: please note thatskew(liketarget) expects absolute values, which need to be different from color space to color space to produce the same results. No shortcuts, bestie. ๐ญ
my @colors = $c->complement( 4 ); # 'quadratic' colors
my @colors = $c->complement( steps => 4, tilt => 1.585 ); # split-complementary colors
my @colors = $c->complement( steps => 3, tilt => 2, target => { l => -10 } );
my @colors = $c->complement( steps => 3, tilt => 2, target => { h => 20, s=> -5, l => -10 });
๐ฆ analogous ๐ฆ
analogous computes analogous colors (GTC objects). These are series of colors where every pair of neighbours differs the same way from each other โ like a little color conga line. ๐
This method may be used to produce a gradient or complementary colors, but it works differently in edge cases and has generally fewer options to shape the result than any of these methods. Its strength? Being able to interpolate from two given colors without having to do much additional computation. Lowkey efficient. โก
The method accepts four named arguments: to, steps, in and tilt. Only to is required, and it can be provided as a positional argument if it's the only one. ๐ซถ
toโ expects a color object or scalar color definition, which will be the color most similar to the starting one (the invocant). It's called the second color here. ๐stepsโ requires a positive integer, which will be the maximal amount of colors produced. The method stops as soon as the generated color is out of range.stepsdefaults to four. ๐inโ sets the color space theanalogouscolors will be computed in, which is OKHSL per default. ๐tiltโ helps you differ from the default behavior, where the distance between two neighbouring colors is always the same. Iftiltis a positive floating point number, this distance will increase; when it's negative, it will shrink.tiltdefaults to zero.
The distance between the starting color and the second color is always taken as 100%. If tilt is for instance 0.2, the distance between the second and the third color will be 120%, or 80% if tilt is -0.2. The distance between the third and fourth color will be 1.2 * 120 = 144% or 64% respectively. In any case, all four colors will be located on one line. ๐
Heads up bestie: please note this line might be curved if the color space is cylindrical. Not a bug, just geometry being geometry. ๐
my @colors = $c->analogous( $second_color ); # 4 analogous colors
my @colors = $c->analogous( to => 'black', steps => 6, in => 'OKLCH', tilt => 0.05 );
๐ฅ gradient ๐ฅ
gradient creates a gradient โ a list of color objects that build a transition โ between the current color held by the object and a second color, provided by the named argument to. That one's required, and it may be provided as a positional argument if it's the only one. The optional arguments are: steps, in and tilt. ๐
toโ expects a color object or scalar color definition, which will be the end color of the gradient. The calling object represents the starting color.
You may also provide an ARRAY reference (square braces) with several independently formatted colors for custom gradients โ it'll incorporate these colors in the order you inserted them into the ARRAY. Order matters, diva. ๐
stepsโ requires a positive integer, which will be the amount of colors produced.stepsdefaults to ten. ๐inโ sets the color space thegradientcolors will be computed in, which is OKLAB per default. ๐งtiltโ moves the colors of the gradient toward the end color or the starting color. The former happens if the floating pointtiltvalue is positive, and the latter if it's negative. The greater the absolutetiltvalue, the greater the effect.tiltdefaults to zero, which results in a gradient of colors with equal distance between them.
Fr fr note this: the effect of tilt is exponential (it is accelerating). So it sneaks up on you โ dramatic on purpose. ๐ญ๐
# we turn to grey
my @colors = $c->gradient( to => 'grey50', steps => 5);
# non-linear gradient in HSL space :
@colors = $c1->gradient( to =>[14,10,222], steps => 10, tilt => 1, in => 'HSL' );
@colors = $c1->gradient( to =>['blue', 'brown', {h => 30, s => 44, l => 50}] );
๐ cluster ๐
cluster computes a set of colors that are similar but not too similar. The calling object sits in the center of the cluster and is always part of the result. The amount of resulting colors depends on the arguments and can greatly vary โ it's giving mystery, honestly. ๐ฎ
The method accepts three named arguments: radius, minimal_distance and in, of which the first two are required. And because typing is hard, radius can be abbreviated as r and minimal_distance as min_d. ๐
radiusโ determines the size of the cluster: the maximal distance between a color of the cluster and the center.
If radius is a floating point number, the cluster will be ball-shaped and packed in a cuboctahedral grid. ๐ซง
If the radius is provided in the form of an ARRAY that contains a floating point number for each axis, there will be a cubic packing that extends on each dimension only as far as the given number for this axis allows. ๐
minimal_distanceโ requires one floating point number that determines the density of the packing, which is the minimal distance in any direction of two neighbouring colors. ๐inโ sets the color space theclustercolors will be computed in, which is OKLAB per default.
Okay important: please note that cuboctahedral packing (when radius is a single number) does not work in CMYK space. Sorry CMYK girlies. ๐๐
my @blues = $blue->cluster( radius => 4, minimal_distance => 0.3 );
my @c = $color->cluster( r => [2,2,3], min_d => 0.4, in => 'YUV' );
๐ AUTHOR ๐
Herbert Breunung, <lichtkind@cpan.org> โจ
๐ COPYRIGHT ๐
Copyright 2026 Herbert Breunung. ๐
๐ธ LICENSE ๐ธ
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Slay, literally. ๐
That's the whole page, bestie โ you ate it up. ๐ซถโจ
Sign-off vibes: this was perl v5.42.2, dated 2026-06-21, from page Graphic...ual::Set(3). Go forth and make pretty color families. ๐จ๐
๐
๐ฆ where this page comes from
- arch rolling: perl-graphics-toolkit-color 2.22-1 ยท Artistic-1.0-Perl AND GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms