public class SColorFactory extends Object
another technique for caching colors that allows filters.
Constructor and Description |
---|
SColorFactory()
Constructs a new SColorFactory with an empty cache.
|
Modifier and Type | Method and Description |
---|---|
SColor |
add(SColor color1,
SColor color2)
Adds the two colors together.
|
void |
addPalette(String name,
ArrayList<SColor> palette)
Places the palette into the cache, along with each of the member colors.
|
void |
addPallet(String name,
ArrayList<SColor> palette)
Deprecated.
Prefer addPalette over this misspelled version; they are equivalent.
|
ArrayList<SColor> |
asGradient(SColor color1,
SColor color2)
Returns a list of colors starting at the first color and moving to the
second color.
|
SColor |
asSColor(com.badlogic.gdx.graphics.Color color)
Returns an SColor representation of the provided Color.
|
SColor |
asSColor(float a,
float r,
float g,
float b)
Returns the cached color that matches the desired rgb value.
|
SColor |
asSColor(int argb)
Returns the cached color that matches the desired rgb value.
|
SColor |
asSColor(int r,
int g,
int b)
Returns an SColor that is opaque.
|
SColor |
asSColor(int a,
int r,
int g,
int b)
Returns an SColor with the given values, with those values clamped
between 0 and 255.
|
SColor |
blend(SColor color1,
SColor color2,
double coef)
Returns an SColor that is the given distance from the first color to the
second color.
|
SColor |
colorForName(String s)
Returns the SColor Constant who's name is the one provided.
|
SColor |
colorForValue(int rgb)
Returns the SColor who's value matches the one passed in.
|
SColor |
desaturate(SColor color,
double percent)
Returns an SColor that is the version of the provided color desaturated
the given amount.
|
SColor |
desaturated(SColor color)
Returns an SColor that is the fully desaturated (greyscale) version of
the provided color.
|
SColor |
dim(SColor color)
Returns an SColor that is a slightly dimmer version of the provided
color.
|
SColor |
dimmer(SColor color)
Returns an SColor that is a somewhat dimmer version of the provided
color.
|
SColor |
dimmest(SColor color)
Returns an SColor that is a lot darker version of the provided color.
|
void |
emptyCache()
Clears the backing cache.
|
SColor |
fromPalette(String name,
float percent)
Returns the SColor that is the provided percent towards the end of the
palette.
|
SColor |
fromPallet(String name,
float percent)
Deprecated.
Prefer fromPalette over this misspelled version; they are equivalent.
|
long |
getFloor()
Gets the value at which each of the red, green, and blue values will be
set to the nearest lower multiple of.
|
SColor |
light(SColor color)
Returns an SColor that is a slightly lighter version of the provided
color.
|
SColor |
lighter(SColor color)
Returns an SColor that is a somewhat lighter version of the provided
color.
|
SColor |
lightest(SColor color)
Returns an SColor that is a lot lighter version of the provided color.
|
SColor |
lightWith(SColor color,
SColor light)
Uses the second color as a light source, meaning that each of the red,
green, and blue values of the first color are multiplied by the lighting
color's percentage of full value (1.0).
|
ArrayList<SColor> |
palette(String name)
Returns the palette associate with the provided name, or null if there is
no such palette.
|
ArrayList<SColor> |
pallet(String name)
Deprecated.
Prefer palette over this misspelled version.
|
int |
quantityCached()
Returns the number of SColor objects currently cached.
|
SColor |
randomBlend(SColor color1,
SColor color2,
double min,
double max)
Returns an SColor that is randomly chosen from the color line between the
two provided colors from the two provided points.
|
void |
setFloor(int value)
Sets the value at which each of the red, green, and blue values will be
set to the nearest lower multiple of.
|
public SColorFactory()
public SColor colorForName(String s)
s
- the namepublic SColor colorForValue(int rgb)
rgb
- an int encoding 256 * 256 * red + 256 * green + bluepublic int quantityCached()
public SColor blend(SColor color1, SColor color2, double coef)
color1
- The first colorcolor2
- The second colorcoef
- The percent towards the second color, as 0.0 to 1.0public SColor randomBlend(SColor color1, SColor color2, double min, double max)
color1
- color2
- min
- The minimum percent towards the second color, as 0.0 to 1.0max
- The maximum percent towards the second color, as 0.0 to 1.0public SColor add(SColor color1, SColor color2)
color1
- color2
- public SColor lightWith(SColor color, SColor light)
color
- light
- public void emptyCache()
public void setFloor(int value)
value
- used to determine the precision of roundingpublic long getFloor()
public SColor asSColor(int argb)
argb
- public SColor asSColor(float a, float r, float g, float b)
a
- r
- g
- b
- public SColor asSColor(int r, int g, int b)
r
- g
- b
- public SColor asSColor(int a, int r, int g, int b)
a
- r
- g
- b
- public SColor asSColor(com.badlogic.gdx.graphics.Color color)
color
- public SColor dim(SColor color)
color
- public SColor dimmer(SColor color)
color
- public SColor dimmest(SColor color)
color
- public SColor light(SColor color)
color
- public SColor lighter(SColor color)
color
- public SColor lightest(SColor color)
color
- public SColor desaturated(SColor color)
color
- public SColor desaturate(SColor color, double percent)
color
- percent
- The percent to desaturate, from 0.0 for none to 1.0 for
fully desaturatedpublic ArrayList<SColor> asGradient(SColor color1, SColor color2)
color1
- starting colorcolor2
- ending colorpublic ArrayList<SColor> palette(String name)
name
- public ArrayList<SColor> pallet(String name)
name
- public SColor fromPalette(String name, float percent)
name
- percent
- public SColor fromPallet(String name, float percent)
name
- percent
- public void addPallet(String name, ArrayList<SColor> palette)
name
- palette
- public void addPalette(String name, ArrayList<SColor> palette)
name
- palette
- Copyright © 2012–2016. All rights reserved.