T - a concrete color typepublic abstract static class IColorCenter.Skeleton<T> extends java.lang.Object implements IColorCenter<T>
IColorCenter.| Modifier and Type | Class and Description |
|---|---|
protected class |
IColorCenter.Skeleton.GranularHasher |
IColorCenter.Skeleton<T>| Modifier and Type | Field and Description |
|---|---|
protected IFilter<T> |
filter |
protected IColorCenter.Skeleton.GranularHasher |
theHasher |
| Modifier | Constructor and Description |
|---|---|
protected |
Skeleton(IFilter<T> filter) |
| Modifier and Type | Method and Description |
|---|---|
int |
cacheSize()
The actual cache is not public, but there are cases where you may want to know how many different colors are
actually used in a frame or a section of the game.
|
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(IRNG rng,
int opacity) |
float |
getSaturation(float r,
float g,
float b) |
float |
getSaturation(T c) |
T |
getTransparent() |
protected long |
getUniqueIdentifier(int r,
int g,
int b,
int a) |
protected long |
getUniqueIdentifier(T item) |
float |
getValue(float r,
float g,
float b) |
float |
getValue(T c) |
T |
getWhite() |
java.util.ArrayList<T> |
gradient(T fromColor,
T toColor)
Finds a gradient with 16 steps going from fromColor to toColor,
both included in the gradient.
|
java.util.ArrayList<T> |
gradient(T fromColor,
T toColor,
int steps)
Finds a gradient with the specified number of steps going from fromColor to toColor,
both included in the gradient.
|
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, waitgetAlpha, getBlue, getGreen, getRedprotected IColorCenter.Skeleton.GranularHasher theHasher
public void clearCache()
public int cacheSize()
clearCache()), some colors were requested, then this is called, the returned int should be the
count of distinct colors this IColorCenter had created and cached; duplicates won't be counted twice.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.thispublic 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). Values outside this range should be treated as wrapping
around, so 1.1f and -0.9f would be the same as 0.1f .saturation - the saturation of the color from 0.0 (a grayscale color; inclusive)
to 1.0 (a bright color, inclusive)value - the value (essentially lightness) of the color from 0.0 (black,
inclusive) to 1.0 (very bright, inclusive).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 (very bright, inclusive).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(IRNG 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 colorfulpublic java.util.ArrayList<T> gradient(T fromColor, T toColor)
IColorCentergradient in interface IColorCenter<T>fromColor - the color to start with, included in the gradienttoColor - the color to end on, included in the gradientpublic java.util.ArrayList<T> gradient(T fromColor, T toColor, int steps)
IColorCentergradient in interface IColorCenter<T>fromColor - the color to start with, included in the gradienttoColor - the color to end on, included in the gradientsteps - the number of elements to use in the gradientprotected 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 colorprotected long getUniqueIdentifier(int r,
int g,
int b,
int a)
protected long getUniqueIdentifier(T item)
Copyright © Eben Howard 2012–2022. All rights reserved.