Package squidpony.squidgrid.gui.gdx
Class Filters.PaletteFilter
java.lang.Object
squidpony.squidgrid.gui.gdx.Filters.PaletteFilter
- All Implemented Interfaces:
IFilter<com.badlogic.gdx.graphics.Color>
- Enclosing class:
- Filters
public static class Filters.PaletteFilter extends Object implements IFilter<com.badlogic.gdx.graphics.Color>
An IFilter that is constructed with a group of colors and forces any color it is told to alter to exactly
the color it was constructed with that has the closest red, green, and blue components. A convenient way to
use this is to pass in one of the color series from SColor, such as
SColor.RED_SERIES
or
SColor.ACHROMATIC_SERIES
. This can also be used to enforce usage of a limited color palette such as
one of DawnBringer's popular pixel art palettes, SColor.DAWNBRINGER_16
and
SColor.DAWNBRINGER_32
. Beyond 32 colors, the palettes SColor.VARIED_PALETTE
with 56 colors
and SColor.COLOR_WHEEL_PALETTE
with 198 colors can be used.
Preview using BLUE_GREEN_SERIES foreground, ACHROMATIC_SERIES background: http://i.imgur.com/2HdZpC9.png-
Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.graphics.Color[]
colorStore
The array of Color objects this will use as a palette. -
Constructor Summary
Constructors Constructor Description PaletteFilter(float[] r, float[] g, float[] b)
Sets up a PaletteFilter with the exact colors to use as individual components; the lengths of each given array should be identical.PaletteFilter(com.badlogic.gdx.graphics.Color[] colors)
Sets up a PaletteFilter with the exact colors to use as Colors. -
Method Summary
Modifier and Type Method Description com.badlogic.gdx.graphics.Color
alter(float r, float g, float b, float a)
-
Field Details
-
colorStore
The array of Color objects this will use as a palette.
-
-
Constructor Details
-
PaletteFilter
Sets up a PaletteFilter with the exact colors to use as individual components; the lengths of each given array should be identical.- Parameters:
r
- the red components to useg
- the green components to useb
- the blue components to use
-
PaletteFilter
Sets up a PaletteFilter with the exact colors to use as Colors. A convenient way to use this is to pass in one of the color series from SColor, such as RED_SERIES or ACHROMATIC_SERIES. The alpha component of each color in the palette is ignored, since when a color is requested for filtering, its alpha is respected and only its red, green, and blue components are changed. Thecolors
array is used verbatim (as a reference, not a copy), so changes to the Color values inside it will change how this PaletteFilter works (possibly badly). If you expect to edit the array you give as a parameter to this, it may be optimal to give a temporary copy.- Parameters:
colors
- the Colors to use as an array; will be referenced in the PaletteFilter, so changing items in this array will change what Colors will be used
-
-
Method Details