Package squidpony.squidgrid.gui.gdx
Class SubcellLayers
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
squidpony.squidgrid.gui.gdx.SparseLayers
squidpony.squidgrid.gui.gdx.SubcellLayers
- All Implemented Interfaces:
IPackedColorPanel
public class SubcellLayers extends SparseLayers
A subclass of SparseLayers that acts almost the same, but uses 3x3 subcells of background color for every cell that
may contain a char. Methods that affect the background sometimes specify positions in subcells, which allows
affecting less than one cell with some visual effect. You will usually want to use a triple-size resistance and FOV
map; you can get a resistance map that respects subcells with
Created by Tommy Ettinger on 8/28/2018.
DungeonUtility.generateResistances3x3(char[][])
(this looks better if it is given
a "line" dungeon as produced by DungeonUtility.hashesToLines(char[][], boolean)
),
and then you can use that resistance map with normal FOV methods, just typically at triple vision range. Much of the
time, it makes sense to run both that triple-range FOV, and a normal-range FOV with a resistance map calculated in
cells; you can use the normal-range FOV for gameplay and AI calculations and the triple-range for visual display.
Created by Tommy Ettinger on 8/28/2018.
-
Field Summary
Fields inherited from class squidpony.squidgrid.gui.gdx.SparseLayers
animationCount, backgrounds, defaultBackground, defaultForeground, defaultPackedBackground, defaultPackedForeground, font, glyphs, gridHeight, gridWidth, layers, mapping, scc
-
Constructor Summary
Constructors Constructor Description SubcellLayers(int gridWidth, int gridHeight)
SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight)
SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font)
SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)
-
Method Summary
Modifier and Type Method Description void
blend(int x, int y, float color, float mixBy)
Using the existing background color at the subcell position x,y, this performs color blending from that existing color to the given color (as a float), using the mixBy parameter to determine how much of the color parameter to use (1f will set the color in this to the parameter, while 0f for mixBy will ignore the color parameter entirely).void
clear(int x, int y)
Removes the foreground chars, where present, in all layers at the given x,y position.void
draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
Draws the SubcellLayers and all glyphs it tracks.void
fillArea(float color, int x, int y, int width, int height)
Changes the background color in an area to all have the given color, as a packed float.void
fillArea(com.badlogic.gdx.graphics.Color color, int x, int y, int width, int height)
Changes the background color in an area to all have the given color, as a libGDX Color (or SColor, etc.).void
put(char[][] chars, float[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given 2D array of colors as packed floats.void
put(char[][] chars, float[][] fgColors, float[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first float 2D array, starting at x=0, y=0, while also setting the background colors to match the second float 2D array.void
put(char[][] chars, com.badlogic.gdx.graphics.Color[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given Color 2D array.void
put(char[][] chars, com.badlogic.gdx.graphics.Color[][] fgColors, com.badlogic.gdx.graphics.Color[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first Color 2D array, starting at x=0, y=0, while also setting the background colors to match the second Color 2D array.void
put(float[][] colors)
Sets the background colors to match the given 2D array of colors as packed floats.void
put(int x, int y, char c, float foreground, float background)
Puts the char c at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, char c, float foreground, float background, int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
Puts the char c at the position x,y with the given foreground and background colors.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors.void
put(int x, int y, float bg)
Changes the background at position x,y to the given color as an encoded float.void
put(int x, int y, com.badlogic.gdx.graphics.Color color)
Changes the background at position x,y to the given Color.void
put(int x, int y, String text, float foreground, float background)
Puts text at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, String text, float foreground, float background, int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
Puts text at the position x,y with the given foreground and background colors.void
put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors.void
put(com.badlogic.gdx.graphics.Color[][] colors)
Sets the background colors to match the given Color 2D array.void
putSingle(int x, int y, float color)
Sets a single subcell of the background to use the specified color as a packed float.void
putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
tint(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
Tints the background at position x,y (in cells) so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.Methods inherited from class squidpony.squidgrid.gui.gdx.SparseLayers
addLayer, addLayer, bump, bump, burst, burst, burst, burst, calculateConsistentLightAmount, calculateConsistentLightModifier, calculateConsistentLightModifier, cellHeight, cellWidth, clear, clear, clear, fillBackground, fillBackground, findLayer, getBackgrounds, getColorCenter, getDefaultBackgroundColor, getDefaultForegroundColor, getFont, getGridHeight, getGridWidth, getLayer, getLayerCount, getScc, glyph, glyph, glyphFromGrid, glyphFromGrid, gridHeight, gridWidth, gridX, gridY, hasActiveAnimations, put, put, put, put, put, put, put, putBorders, putBordersCaptioned, putChars, putChars, putChars, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseLight, putWithReverseLight, recallToGrid, recallToGrid, recolor, recolor, recolor, recolor, recolor, recolor, recolor, recolor, removeGlyph, setBackgrounds, setColorCenter, setDefaultBackground, setDefaultForeground, setFont, setLayer, setScc, setTextSize, slide, slide, summon, summon, summon, summon, tint, tint, tint, tint, tint, tint, tint, wiggle, wiggle, worldX, worldY
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
-
Constructor Details
-
SubcellLayers
-
SubcellLayers
-
SubcellLayers
public SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font) -
SubcellLayers
public SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)
-
-
Method Details
-
put
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given Color 2D array. The colors 2D array should have a width that is 3 *SparseLayers.gridWidth
and a height that is 3 *SparseLayers.gridHeight
. If the colors argument is null, does not affect backgrounds but may still affect chars. If the chars argument is null, only affects the background colors. This will filter each Color in colors if the color center this uses has a filter.- Specified by:
put
in interfaceIPackedColorPanel
- Overrides:
put
in classSparseLayers
- Parameters:
chars
- Can benull
, indicating that only colors must be put.colors
- the background colors for the given chars; this array should have 3 times the width and height of chars
-
put
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given 2D array of colors as packed floats. The colors 2D array should have a width that is 3 *SparseLayers.gridWidth
and a height that is 3 *SparseLayers.gridHeight
. If the colors argument is null, does not affect backgrounds but may still affect chars. If the chars argument is null, only affects the background colors. This will not filter the passed colors at all.- Overrides:
put
in classSparseLayers
- Parameters:
chars
- Can benull
, indicating that only colors must be put.colors
- the background colors for the given chars; this array should have 3 times the width and height of chars
-
put
public void put(char[][] chars, com.badlogic.gdx.graphics.Color[][] fgColors, com.badlogic.gdx.graphics.Color[][] bgColors)Places the given char 2D array, if-non-null, with the given foreground colors in the first Color 2D array, starting at x=0, y=0, while also setting the background colors to match the second Color 2D array. If the bgColors argument is null, only affects foreground chars and colors. If the chars argument or the fgColors argument is null, only affects the background colors. Any positions where a Color in fgColors is null will not have a char placed (this can be used to restrict what is placed). This will filter each Color in the background and foreground if the color center this uses has a filter.- Overrides:
put
in classSparseLayers
- Parameters:
chars
- Can benull
, indicating that only colors must be put.fgColors
- the foreground Colors for the given charsbgColors
- the background Colors for the given chars; this array should have 3 times the width and height of chars
-
put
Places the given char 2D array, if-non-null, with the given foreground colors in the first float 2D array, starting at x=0, y=0, while also setting the background colors to match the second float 2D array. If the bgColors argument is null, only affects foreground chars and colors. If the chars argument or the fgColors argument is null, only affects the background colors. Any positions where a float in fgColors is 0 will not have a char placed (this can be used to restrict what is placed). This will not filter any colors.- Overrides:
put
in classSparseLayers
- Parameters:
chars
- Can benull
, indicating that only colors must be put.fgColors
- the foreground colors for the given chars, as packed floatsbgColors
- the background colors for the given chars, as packed floats; this array should have 3 times the width and height of chars
-
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)Puts the char c at the position x,y with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withSparseLayers.setScc(IColorCenter)
.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null, nothing will change in the background
-
put
Puts the char c at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the background
-
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)Puts the char c at the position x,y in the requested layer with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withSparseLayers.setColorCenter(IColorCenter)
. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal toSparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a sane way.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andSparseLayers.getLayerCount()
inclusive
-
put
Puts the char c at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal toSparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a sane way.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andSparseLayers.getLayerCount()
inclusive
-
put
public void put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)Puts text at the position x,y with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withSparseLayers.setColorCenter(IColorCenter)
.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the background
-
put
Puts text at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the background
-
put
public void put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)Puts text at the position x,y in the requested layer with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withSparseLayers.setColorCenter(IColorCenter)
. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal toSparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a sane way.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andSparseLayers.getLayerCount()
inclusive
-
put
Puts text at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal toSparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a sane way.- Overrides:
put
in classSparseLayers
- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andSparseLayers.getLayerCount()
inclusive
-
put
Changes the background at position x,y to the given Color. If the color is null, then this will make the background fully transparent at the specified position.- Specified by:
put
in interfaceIPackedColorPanel
- Overrides:
put
in classSparseLayers
- Parameters:
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatecolor
- the Color to change to; if null will be considered fully transparent
-
put
Changes the background at position x,y to the given color as an encoded float. The color can be transparent, which will show through to whatever is behind this SparseLayers, or the color the screen was last cleared with. Unlike other methods in this class, a float equal to 0f will be used instead of being used to skip over a cell, and will change the background at the given position to fully transparent.- Specified by:
put
in interfaceIPackedColorPanel
- Overrides:
put
in classSparseLayers
- Parameters:
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatebg
- the color, as an encoded float, to change to; may be transparent, and considers 0f a valid color
-
putWithLight
public void putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Overrides:
putWithLight
in classSparseLayers
- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited
-
putWithLight
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Overrides:
putWithLight
in classSparseLayers
- Parameters:
x
- the x position, in subcells (3 subcells in a row have the width of one character cell)y
- the y position, in subcells (3 subcells in a column have the height of one character cell)background
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from the putWithLight methods that take a Noise3D argument, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Overrides:
putWithConsistentLight
in classSparseLayers
- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from the putWithLight methods that take a Noise3D argument, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Overrides:
putWithConsistentLight
in classSparseLayers
- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putSingle
Sets a single subcell of the background to use the specified color as a packed float. The values given for x and y refer to a triple-width, triple-height grid, so the meaning of x and y are different here from other methods. If you want to set the center subcell of the cell that would normally be set withput(int, int, char, float, float)
at the position x=20,y=30, this would set that subcell at x=20*3+1,y=30*3+1 , where the *3 gets the x and y to refer to the correct 3x3 subcell grid, and the +1 chooses the subcell as one to the right and one down.- Parameters:
x
- the x position in the triple-width, triple-height grid of background subcellsy
- the y position in the triple-width, triple-height grid of background subcellscolor
- a packed float color to place in the background of one subcell
-
put
Sets the background colors to match the given Color 2D array. The colors 2D array should have a width that is 3 *SparseLayers.gridWidth
and a height that is 3 *SparseLayers.gridHeight
. If the colors argument is null, does nothing. This will filter each Color in colors if the color center this uses has a filter.- Overrides:
put
in classSparseLayers
- Parameters:
colors
- the background colors for the given chars
-
put
Sets the background colors to match the given 2D array of colors as packed floats. The colors 2D array should have a width that is 3 *SparseLayers.gridWidth
and a height that is 3 *SparseLayers.gridHeight
. If the colors argument is null, does nothing. This will not filter the passed colors at all.- Overrides:
put
in classSparseLayers
- Parameters:
colors
- the background colors to use for this SparseLayers
-
clear
Removes the foreground chars, where present, in all layers at the given x,y position. The backgrounds will be unchanged.- Specified by:
clear
in interfaceIPackedColorPanel
- Overrides:
clear
in classSparseLayers
- Parameters:
x
- the x-coordinate of the position to remove all chars fromy
- the y-coordinate of the position to remove all chars from
-
fillArea
Changes the background color in an area to all have the given color, as a libGDX Color (or SColor, etc.). This uses subcell measurements for x, y, width, and height, where the grid width in subcells is 3 *SparseLayers.gridWidth
and the grid height in subcells is 3 *SparseLayers.gridHeight
. To affect a full cell, this needs a width and height of at least 3 each; anything less will affect only some subcells.- Overrides:
fillArea
in classSparseLayers
- Parameters:
color
- a libGDX Color to fill the area with; may be null to make the background transparentx
- left edge's x coordinate, in subcells (3 subcells to one cell horizontally)y
- top edge's y coordinate, in subcells (3 subcells to one cell vertically)width
- the width of the area to change the color on, in subcells (3 subcells to one cell horizontally)height
- the height of the area to change the color on, in subcells (3 subcells to one cell vertically)
-
fillArea
Changes the background color in an area to all have the given color, as a packed float. This uses subcell measurements for x, y, width, and height, where the grid width in subcells is 3 *SparseLayers.gridWidth
and the grid height in subcells is 3 *SparseLayers.gridHeight
. To affect a full cell, this needs a width and height of at least 3 each; anything less will affect only some subcells.- Overrides:
fillArea
in classSparseLayers
- Parameters:
color
- a color as a packed float to fill the area with; may be 0f to make the background transparentx
- left edge's x coordinate, in subcells (3 subcells to one cell horizontally)y
- top edge's y coordinate, in subcells (3 subcells to one cell vertically)width
- the width of the area to change the color on, in subcells (3 subcells to one cell horizontally)height
- the height of the area to change the color on, in subcells (3 subcells to one cell vertically)
-
blend
Using the existing background color at the subcell position x,y, this performs color blending from that existing color to the given color (as a float), using the mixBy parameter to determine how much of the color parameter to use (1f will set the color in this to the parameter, while 0f for mixBy will ignore the color parameter entirely). The x and y parameters are in subcells, where 3 subcells have the same width or height as one cell (a cell holds a char, and 3x3 subcells fit in the same area).- Specified by:
blend
in interfaceIPackedColorPanel
- Overrides:
blend
in classSparseLayers
- Parameters:
x
- the x component of the position in this panel to draw the starting color fromy
- the y component of the position in this panel to draw the starting color fromcolor
- the new color to mix with the starting color; a packed float, as made byColor.toFloatBits()
mixBy
- the amount by which the new color will affect the old one, between 0 (no effect) and 1 (overwrite)
-
tint
public void tint(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)Tints the background at position x,y (in cells) so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueuepostRunnable
for running after the created action ends. All subcells in the tinted cell will reach the same color during this animation, but the subcells can start with different colors, and they will return to those starting colors after this animation finishes.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Overrides:
tint
in classSparseLayers
- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in secondspostRunnable
- a Runnable to execute after the tint completes; may be null to do nothing.
-
draw
Draws the SubcellLayers and all glyphs it tracks.Batch.begin()
must have already been called on the batch, andBatch.end()
should be called after this returns and before the rendering code finishes for the frame.
This will set the shader ofbatch
if using a distance field or MSDF font and the shader is currently not configured for such a font; it does not reset the shader to the default so that multiple Actors can all use the same shader and so specific extra glyphs or other items can be rendered after calling draw(). If you need to draw both a distance field font and full-color art, you should set the shader on the Batch to null when you want to draw full-color art, and end the Batch between drawing this object and the other art.- Overrides:
draw
in classSparseLayers
- Parameters:
batch
- a Batch such as aFilterBatch
that must be between a begin() and end() call; usually done by StageparentAlpha
- currently ignored
-