Package squidpony.squidgrid.gui.gdx
Class FloatFilters.YCwCmFilter
java.lang.Object
squidpony.squidgrid.gui.gdx.FloatFilter
squidpony.squidgrid.gui.gdx.FloatFilters.YCwCmFilter
- Enclosing class:
- FloatFilters
public static class FloatFilters.YCwCmFilter extends FloatFilter
Like
Valid values for Cw and Cm are from -1.0 to 1.0, but there aren't really invalid values here because this filter will clamp results with higher or lower channel values than a color can have. Each of yMul, cwMul, and cmMul can have any float value, but yMul should be positive (unless you want this to only produce solid black). Similarly, cwMul and cmMul will not produce meaningful results if they are very large (either positive or negative); it's recommended to use values between 0.0 and 1.0 for both if you want to desaturate colors or values somewhat greater than 1.0 to oversaturate them. Unlike
FloatFilters.YCbCrFilter
or FloatFilters.YCoCgFilter
, but edits its input colors in YCwCm color space, which is very
similar to YCoCg but has chroma/chrominance components that are useful aesthetically on their own. You may often
prefer FloatFilters.YCbCrFilter
because it calculates lightness (luma) more precisely, but the Cb (blue-ness) and Cr
(red-ness) components are less useful for some purposes individually. Y is luminance, ranging from 0 (dark) to 1
(light), and affects how bright the color is, but isn't very accurate perceptually. Cw is Chroma(warm) and
Cm is Chroma(mild) (both range from -1.0 to 1.0), two inter-related channels that determine the hue and vividness
of a specific color. When Cw and Cm are both 0, the color is grayscale. When Cw is 1 and Cm is -1, the color
is red or like red. When Cw is -1 and Cm is 1, the color is green or like green. When Cw and Cm are both -1, the
color is blue or like blue, and when both are 1, the color is roughly yellow or brown (depending on Y).
Valid values for Cw and Cm are from -1.0 to 1.0, but there aren't really invalid values here because this filter will clamp results with higher or lower channel values than a color can have. Each of yMul, cwMul, and cmMul can have any float value, but yMul should be positive (unless you want this to only produce solid black). Similarly, cwMul and cmMul will not produce meaningful results if they are very large (either positive or negative); it's recommended to use values between 0.0 and 1.0 for both if you want to desaturate colors or values somewhat greater than 1.0 to oversaturate them. Unlike
FloatFilters.YCbCrFilter
and FloatFilters.YCoCgFilter
, you can benefit from
setting cwMul independently of the other chroma component, which can be used to emphasize warm vs. cool colors if
cwMul is greater than 1.0, or to de-emphasize that comparison if it is between 0.0 and 1.0. A similar option is
possible for cmMul, but it isn't as clear of an artistic convention; a high cmMul will separate green-and-yellow
colors further from red-purple-and-blue colors. Also unlike the other YCC filters, this allows an additive change
to Y, Cw, and Cm applied after the multiplicative change but before converting to RGB and clamping. This can be
used to make all colors warmer or cooler (such as for volcano or frozen scenes) by adding or subtracting from Cw,
for instance. It can also lighten or darken all colors by changing luma.-
Field Summary
-
Constructor Summary
Constructors Constructor Description YCwCmFilter(float yMul, float cwMul, float cmMul)
YCwCmFilter(float yMul, float cwMul, float cmMul, float yAdd, float cwAdd, float cmAdd)
-
Method Summary
Modifier and Type Method Description float
alter(float color)
Takes a packed float color and produces a potentially-different packed float color that this FloatFilter edited.
-
Field Details
-
Constructor Details
-
Method Details
-
alter
Takes a packed float color and produces a potentially-different packed float color that this FloatFilter edited.- Specified by:
alter
in classFloatFilter
- Parameters:
color
- a packed float color, as produced byColor.toFloatBits()
- Returns:
- a packed float color, as produced by
Color.toFloatBits()
-