T
- a concrete color typepublic abstract static class IColorCenter.Skeleton<T> extends Object implements IColorCenter<T>
IColorCenter
.IColorCenter.Skeleton<T>
Modifier | Constructor and Description |
---|---|
protected |
Skeleton(IFilter<T> filter) |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
It clears the cache.
|
void |
copyCache(IColorCenter.Skeleton<T> other)
You may want to copy colors between IColorCenter instances that have different create() methods -- and as
such, will have different values for the same keys in the cache.
|
protected abstract T |
create(int red,
int green,
int blue,
int opacity)
Create a concrete instance of the color type given as a type parameter.
|
T |
desaturate(T color,
float degree)
Brings a color closer to grayscale by the specified degree and returns the new color (desaturated somewhat).
|
T |
desaturated(T color)
Gets a fully-desaturated version of the given color (keeping its brightness, but making it grayscale).
|
IColoredString<T> |
filter(IColoredString<T> ics) |
T |
filter(T c) |
T |
get(int red,
int green,
int blue) |
T |
get(int red,
int green,
int blue,
int opacity) |
T |
getBlack() |
T |
getHSV(float hue,
float saturation,
float value) |
T |
getHSV(float hue,
float saturation,
float value,
float opacity) |
float |
getHue(float r,
float g,
float b) |
float |
getHue(T c) |
T |
getRandom(RNG rng,
int opacity) |
float |
getSaturation(float r,
float g,
float b) |
float |
getSaturation(T c) |
T |
getTransparent() |
float |
getValue(float r,
float g,
float b) |
float |
getValue(T c) |
T |
getWhite() |
T |
greify(T t,
boolean doAlpha)
Gets a copy of t and modifies it to make a shade of gray with the same brightness.
|
T |
lerp(T start,
T end,
float change)
Gets the linear interpolation from Color start to Color end, changing by the fraction given by change.
|
T |
saturate(T color,
float degree)
Saturates color (makes it closer to a vivid color like red or green and less gray) by the specified degree and
returns the new color (saturated somewhat).
|
T |
saturated(T color)
Fully saturates color (makes it a vivid color like red or green and less gray) and returns the modified copy.
|
IColorCenter.Skeleton<T> |
setFilter(IFilter<T> filter)
If you're changing the filter, you should likely call
clearCache() . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAlpha, getBlue, getGreen, getRed
public void clearCache()
public void copyCache(IColorCenter.Skeleton<T> other)
other
- another Skeleton of the same type that will have its cache copied into this Skeletonpublic IColorCenter.Skeleton<T> setFilter(IFilter<T> filter)
clearCache()
.filter
- The filter to use, or null
to turn filtering OFF.this
public T get(int red, int green, int blue, int opacity)
get
in interface IColorCenter<T>
red
- The red component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).green
- The green component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).blue
- The blue component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).opacity
- The alpha component. In-between 0 (inclusive) and 256
(exclusive). Larger values mean more opacity; 0 is clear.public T get(int red, int green, int blue)
get
in interface IColorCenter<T>
red
- The red component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).green
- The green component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).blue
- The blue component. For screen colors, in-between 0 (inclusive)
and 256 (exclusive).public T getHSV(float hue, float saturation, float value, float opacity)
getHSV
in interface IColorCenter<T>
hue
- The hue of the desired color from 0.0 (red, inclusive) towards orange, then
yellow, and eventually to purple before looping back to almost the same red
(1.0, exclusive)saturation
- the saturation of the color from 0.0 (a grayscale color; inclusive)
to 1.0 (a bright color, exclusive)value
- the value (essentially lightness) of the color from 0.0 (black,
inclusive) to 1.0 (inclusive) for screen colors or arbitrarily high
for HDR colors.opacity
- the alpha component as a float; 0.0f is clear, 1.0f is opaque.public T getHSV(float hue, float saturation, float value)
getHSV
in interface IColorCenter<T>
hue
- The hue of the desired color from 0.0 (red, inclusive) towards orange, then
yellow, and eventually to purple before looping back to almost the same red
(1.0, exclusive)saturation
- the saturation of the color from 0.0 (a grayscale color; inclusive)
to 1.0 (a bright color, exclusive)value
- the value (essentially lightness) of the color from 0.0 (black,
inclusive) to 1.0 (inclusive) for screen colors or arbitrarily high
for HDR colors.public T getWhite()
getWhite
in interface IColorCenter<T>
public T getBlack()
getBlack
in interface IColorCenter<T>
public T getTransparent()
getTransparent
in interface IColorCenter<T>
public T getRandom(RNG rng, int opacity)
getRandom
in interface IColorCenter<T>
rng
- an RNG from SquidLib.opacity
- The alpha component. In-between 0 (inclusive) and 256
(exclusive). Larger values mean more opacity; 0 is clear.public float getSaturation(float r, float g, float b)
r
- the red component in 0.0 to 1.0 range, typicallyg
- the green component in 0.0 to 1.0 range, typicallyb
- the blue component in 0.0 to 1.0 range, typicallypublic float getSaturation(T c)
getSaturation
in interface IColorCenter<T>
c
- a concrete colorpublic float getValue(float r, float g, float b)
r
- the red component in 0.0 to 1.0 range, typicallyg
- the green component in 0.0 to 1.0 range, typicallyb
- the blue component in 0.0 to 1.0 range, typicallypublic float getValue(T c)
getValue
in interface IColorCenter<T>
c
- a concrete colorpublic float getHue(float r, float g, float b)
r
- the red component in 0.0 to 1.0 range, typicallyg
- the green component in 0.0 to 1.0 range, typicallyb
- the blue component in 0.0 to 1.0 range, typicallypublic float getHue(T c)
getHue
in interface IColorCenter<T>
c
- a concrete colorpublic T filter(T c)
filter
in interface IColorCenter<T>
this
shows when c
is requested. May be c
itself.public IColoredString<T> filter(IColoredString<T> ics)
filter
in interface IColorCenter<T>
ics
filtered according to IColorCenter.filter(Object)
. May be
ics
itself if unchanged.public T greify(T t, boolean doAlpha)
greify
in interface IColorCenter<T>
t
- a T to copy; only the copy will be modifieddoAlpha
- Whether to include (and hereby change) the alpha component.t
.public T lerp(T start, T end, float change)
lerp
in interface IColorCenter<T>
start
- the initial color Tend
- the "target" color Tchange
- the degree to change closer to end; a change of 0.0f produces start, 1.0f produces endpublic T desaturated(T color)
desaturated
in interface IColorCenter<T>
color
- the color T to desaturate (will not be modified)public T desaturate(T color, float degree)
desaturate
in interface IColorCenter<T>
color
- the color T to desaturatedegree
- a float between 0.0f and 1.0f; more makes it less colorfulpublic T saturated(T color)
saturated
in interface IColorCenter<T>
color
- the color T to saturate (will not be modified)public T saturate(T color, float degree)
saturate
in interface IColorCenter<T>
color
- the color T to saturatedegree
- a float between 0.0f and 1.0f; more makes it more colorfulprotected abstract T create(int red, int green, int blue, int opacity)
filter
.red
- the red component of the desired colorgreen
- the green component of the desired colorblue
- the blue component of the desired coloropacity
- the alpha component or opacity of the desired colorCopyright © 2012–2016. All rights reserved.