Class SparseLayers

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
squidpony.squidgrid.gui.gdx.SparseLayers
All Implemented Interfaces:
IPackedColorPanel
Direct Known Subclasses:
SquidMessageBox, SubcellLayers

public class SparseLayers
extends com.badlogic.gdx.scenes.scene2d.Actor
implements IPackedColorPanel
A general-purpose char display grid that supports one layer of backgrounds and arbitrarily many layers of foreground, only rendering foreground chars when something is present at a char's location. This also stores an ArrayList of TextCellFactory.Glyph items that can be added to using glyph(char, Color, int, int) or one of several other methods; these Glyphs can have effects performed on them that are analogous to the effects on SquidPanel's AnimatedEntity effects, such as slide(TextCellFactory.Glyph, int, int, int, int, float, Runnable). Unlike SquidPanel and SquidLayers, this class does not typically provide many overloads for each method, and usually limits the overloads to one that takes a packed float color and one that takes a libGDX Color, and all the other parameters are expected to be specified explicitly rather than relying on default behavior. SparseLayers tends to perform better than SquidLayers, especially when a lot of the map is unassigned/blank. It will cause less GC pressure when packed floats are used, and because SColor constants pre-calculate their packed float values, using the overloads that take a Color will perform a little better when given an SColor than a plain libGDX Color. This class makes heavy use of SColor.lerpFloatColors(float, float, float) because it should cause no GC pressure (it doesn't create temporary Color objects), and if you don't want to mutate Colors in-place (which is a bad idea for constants), then using lerpFloatColors with the packed float color API here should be very effective.
The names are a little different for some member fields here; there's a TextCellFactory called font, a float[][] called backgrounds that stores packed float colors, an ArrayList of SparseTextMap that implements the sparse drawing behavior of foreground chars called layers, and so on.
Created by Tommy Ettinger on 7/28/2017.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int animationCount
    Deprecated.
    Use hasActiveAnimations() instead of adjusting this manually
    float[][] backgrounds
    A 2D float array of background colors as packed floats.
    com.badlogic.gdx.graphics.Color defaultBackground
    The default foreground color when none is specified, as a Color object.
    com.badlogic.gdx.graphics.Color defaultForeground
    The default foreground color when none is specified, as a Color object.
    float defaultPackedBackground
    The value of defaultForeground as a float, for easier usage with the methods that use floats for colors.
    float defaultPackedForeground
    The value of defaultForeground as a float, for easier usage with the methods that use floats for colors.
    TextCellFactory font
    The TextCellFactory that is used to determine font size as well as cell size; must be initialized, usually using TextCellFactory.initBySize(), if this is changed after construction.
    ArrayList<TextCellFactory.Glyph> glyphs
    A list of individually-movable Glyph objects.
    int gridHeight  
    int gridWidth  
    ArrayList<SparseTextMap> layers
    A list of SparseTextMap objects, with each representing a foreground layer.
    protected com.badlogic.gdx.utils.IntIntMap mapping  
    IColorCenter<com.badlogic.gdx.graphics.Color> scc
    An IColorCenter to affect color caching and filtering; usually a SquidColorCenter, which can be easily obtained via DefaultResources.getSCC().
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected SparseLayers()  
      SparseLayers​(int gridWidth, int gridHeight)  
      SparseLayers​(int gridWidth, int gridHeight, float cellWidth, float cellHeight)  
      SparseLayers​(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font)  
      SparseLayers​(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)  
  • Method Summary

    Modifier and Type Method Description
    SparseTextMap addLayer()
    Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added.
    SparseTextMap addLayer​(int association)
    Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added, or returns an existing layer if one is already associated with the given number.
    void blend​(int x, int y, float color, float mixBy)
    Using the existing background color at the 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 bump​(float delay, TextCellFactory.Glyph glyph, Direction direction, float duration, Runnable postRunnable)
    Start a bumping animation in the given direction after delay seconds, that will last duration seconds; runs postRunnable after the duration completes if postRunnable is non-null.
    void bump​(TextCellFactory.Glyph glyph, Direction direction, float duration)
    Start a bumping animation in the given direction that will last duration seconds.
    void burst​(float delay, int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
    Convenience method to produce an explosion, splash, or burst effect.
    void burst​(float delay, int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration, Runnable postRunnable)
    Convenience method to produce an explosion, splash, or burst effect.
    void burst​(int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration)
    Convenience method to produce an explosion, splash, or burst effect.
    void burst​(int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration)
    Convenience method to produce an explosion, splash, or burst effect.
    float calculateConsistentLightAmount​(float lightAmount, float modifier)
    Allows you to reproduce the effects of putWithConsistentLight(int, int, char, float, float, float, double, float) without recalculating the modifier many times per frame.
    float calculateConsistentLightModifier()
    Gets a modifier that should be given to calculateConsistentLightAmount(float, float); this only needs to be called at most once per frame.
    float calculateConsistentLightModifier​(float flickerSpeed)
    Gets a modifier that should be given to calculateConsistentLightAmount(float, float); this only needs to be called at most once per frame.
    int cellHeight()  
    int cellWidth()  
    void clear()
    Removes all background colors, setting them to transparent, and all foreground chars in all layers.
    void clear​(int layer)
    Removes all foreground chars in the requested layer; does not affect the background or other layers.
    void clear​(int x, int y)
    Removes the foreground chars, where present, in all layers at the given x,y position.
    void clear​(int x, int y, int layer)
    Removes the foreground char, if present, in the given layer at the given x,y position.
    void draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
    Draws the SparseLayers 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 fillBackground​(float color)
    Fills all of the background with the given color as a packed float.
    void fillBackground​(com.badlogic.gdx.graphics.Color color)
    Fills all of the background with the given color as libGDX Color object.
    int findLayer​(SparseTextMap layerMap)
    Finds the layer number associated with layerMap, or -1 if the given SparseTextMap is not in this SparseLayers.
    float[][] getBackgrounds()
    Gets a direct reference to the 2D float array this uses for background colors.
    IColorCenter<com.badlogic.gdx.graphics.Color> getColorCenter()
    Gets the IColorCenter this can use to filter Color objects; this is usually a SquidColorCenter.
    com.badlogic.gdx.graphics.Color getDefaultBackgroundColor()  
    com.badlogic.gdx.graphics.Color getDefaultForegroundColor()  
    TextCellFactory getFont()
    Gets a direct reference to the TextCellFactory this uses to draw and size its text items and cells.
    int getGridHeight()
    The same as gridHeight(); here for compatibility with SquidPanel.
    int getGridWidth()
    The same as gridWidth(); here for compatibility with SquidPanel.
    SparseTextMap getLayer​(int layer)
    Gets the layer, as a SparseTextMap, that is associated with the given int.
    int getLayerCount()
    Gets the number of layers currently used in this SparseLayers; if a layer is put into that is equal to or greater than this layer count, then a new layer is created to hold the latest placement.
    IColorCenter<com.badlogic.gdx.graphics.Color> getScc()
    Gets the IColorCenter for Color objects (almost always a SquidColorCenter, but this isn't guaranteed) that this uses to cache and possibly alter Colors that given to it as parameters.
    TextCellFactory.Glyph glyph​(char shown, float color, int x, int y)
    Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers.
    TextCellFactory.Glyph glyph​(char shown, com.badlogic.gdx.graphics.Color color, int x, int y)
    Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers.
    TextCellFactory.Glyph glyphFromGrid​(int x, int y)
    "Promotes" a colorful char in the first layer to a Glyph that can be positioned independently of the contents of this SparseLayers.
    TextCellFactory.Glyph glyphFromGrid​(int x, int y, int layer)
    "Promotes" a colorful char in the given layer to a Glyph that can be positioned independently of the contents of this SparseLayers.
    int gridHeight()  
    int gridWidth()  
    int gridX​(float worldX)
    Used internally to go between world positions and grid positions.
    int gridY​(float worldY)
    Used internally to go between world positions and grid positions.
    boolean hasActiveAnimations()
    Gets whether any animations or other scene2d Actions are running on this SparseLayers.
    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)
    Puts the character c at (x, y) with the default foreground.
    void put​(int x, int y, char c, float foreground)
    Puts the char c at the position x,y with the given foreground color as an encoded float (the kind produced by Color.toFloatBits()).
    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 by Color.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 by Color.toFloatBits().
    void put​(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
    Puts the character c at (x, y) with some color.
    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 color)
    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 by Color.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 by Color.toFloatBits().
    void put​(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground)
    Puts the given string horizontally with the first character at the given offset.
    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​(int xOffset, int yOffset, IColoredString<? extends com.badlogic.gdx.graphics.Color> cs)
    Puts the given string horizontally with the first character at the given offset, using the colors that cs provides.
    void put​(int x, int y, ICellVisible cell)
    Puts the ICellVisible cell at the position x,y; does not change the background.
    void put​(int x, int y, ICellVisible cell, float background)
    Puts the ICellVisible cell at the position x,y with the given background color as an encoded float, such as those produced by Color.toFloatBits().
    void put​(com.badlogic.gdx.graphics.Color[][] colors)
    Sets the background colors to match the given Color 2D array.
    void putBorders​(float color, String caption)  
    void putBordersCaptioned​(float color, IColoredString<com.badlogic.gdx.graphics.Color> caption)  
    void putChars​(char[][] chars)
    Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0.
    void putChars​(char[][] chars, float[][] foregrounds)
    Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0.
    void putChars​(char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds)
    Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0.
    void putWithConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, double 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 putWithConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, double 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, char c, float foreground, 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 putWithConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithConsistentLight​(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 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)
    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, char c, float foreground, float background, float lightColor, double lightAmount)
    A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
    void putWithLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
    A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
    void putWithLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
    A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.
    void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)
    A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
    void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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, while also putting a char on the screen; as a whole this affects one x,y position.
    void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
    A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.
    void putWithLight​(int x, int y, float background, float lightColor, double 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, 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, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
    A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.
    void putWithLight​(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double 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 putWithLight​(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
    A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.
    void putWithReverseConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
    A convenience method that handles blending the foreground 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 and placed the background as-is.
    void putWithReverseConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, float flickerSpeed)
    A convenience method that handles blending the foreground 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 and placed the background as-is.
    void putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double 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 putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithReverseLight​(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
    A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
    void putWithReverseLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
    A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
    void recallToGrid​(TextCellFactory.Glyph glyph)
    Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the first layer with the Glyph's char and color.
    void recallToGrid​(TextCellFactory.Glyph glyph, int layer)
    Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the given layer with the Glyph's char and color.
    void recolor​(float delay, int x, int y, float encodedColor, float duration)
    Changes the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds.
    void recolor​(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
    Changes the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds.
    void recolor​(float delay, int x, int y, int layer, float encodedColor, float duration)
    Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds.
    void recolor​(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
    Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds.
    void recolor​(int x, int y, float encodedColor, float duration)
    Changes the background at position x,y so it becomes the given encodedColor, taking duration seconds.
    void recolor​(int x, int y, int layer, float encodedColor, float duration)
    Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, taking duration seconds.
    void recolor​(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
    Changes the foreground in the given layer at position x,y so it becomes the given color, taking duration seconds.
    void recolor​(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
    Changes the background at position x,y so it becomes the given color, taking duration seconds.
    void removeGlyph​(TextCellFactory.Glyph glyph)
    A way to remove a Glyph from the group of glyphs this renders, while also ending any animations or other Actions that the removed Glyph was scheduled to perform.
    void setBackgrounds​(float[][] backgrounds)
    Changes the reference this uses for the float array for background colors; this will not accept null parameters, nor will it accept any 2D array with dimensions that do not match the (unchanging) gridWidth and gridHeight of this SparseLayers.
    protected void setColorCenter​(IColorCenter<com.badlogic.gdx.graphics.Color> icc)
    Method to change the backing IColorCenter.
    void setDefaultBackground​(com.badlogic.gdx.graphics.Color color)
    Sets the default background color.
    void setDefaultForeground​(com.badlogic.gdx.graphics.Color color)
    Sets the default foreground color.
    void setFont​(TextCellFactory font)
    Sets the TextCellFactory this uses to draw and size its text items and cells.
    void setLayer​(int layerNumber, SparseTextMap contents)
    Sets the SparseTextMap associated with the given layerNumber to the given contents.
    void setScc​(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
    Sets the IColorCenter for Color objects that this uses to cache and modify Colors given to it; does not accept null parameters.
    SparseLayers setTextSize​(float wide, float high)
    Changes the width and height of chars the font renders, inside the same cell size.
    void slide​(float delay, TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
    Slides glyph from (xstartX,startY) to (newx, newy) after waiting delay seconds.
    void slide​(TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
    Slides glyph from (xstartX,startY) to (newx, newy).
    void summon​(float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration)
    Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before removing the Glyph.
    void summon​(float delay, float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
    Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
    void summon​(float delay, int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
    Create a new Glyph at (startX, startY) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
    void summon​(int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration)
    Create a new Glyph at (startX, startY) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Glyph.
    void tint​(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
    Tints the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
    Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(float delay, TextCellFactory.Glyph glyph, float encodedColor, float duration, Runnable postRunnable)
    Tints the given glyph (which may or may not be part of the glyphs list this holds) so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(int x, int y, float encodedColor, float duration)
    Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(int x, int y, int layer, float encodedColor, float duration)
    Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
    Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
    Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void tint​(TextCellFactory.Glyph glyph, float encodedColor, float duration)
    Tints the given glyph (which may or may not be part of the glyphs list this holds) so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
    void wiggle​(float delay, TextCellFactory.Glyph glyph, float duration, Runnable postRunnable)
    Starts a wiggling animation for the object at the given location, after waiting delay seconds, for the given duration in seconds; runs postRunnable afterwards if it is non-null.
    void wiggle​(TextCellFactory.Glyph glyph, float duration)
    Starts an wiggling animation for the object at the given location for the given duration in seconds.
    float worldX​(int gridX)
    Used internally to go between grid positions and world positions.
    float worldY​(int gridY)
    Used internally to go between grid positions and world positions.

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • gridWidth

      public int gridWidth
    • gridHeight

      public int gridHeight
    • backgrounds

      public float[][] backgrounds
      A 2D float array of background colors as packed floats. Must have dimensions matching gridWidth and gridHeight, and must be non-null with non-null interior arrays, but can otherwise be assigned 2D float arrays from other sources (that use floats to represent colors, not just any number).
    • defaultForeground

      public com.badlogic.gdx.graphics.Color defaultForeground
      The default foreground color when none is specified, as a Color object. Defaults to white.
    • defaultBackground

      public com.badlogic.gdx.graphics.Color defaultBackground
      The default foreground color when none is specified, as a Color object. Defaults to white.
    • defaultPackedForeground

      The value of defaultForeground as a float, for easier usage with the methods that use floats for colors. Defaults to white.
    • defaultPackedBackground

      The value of defaultForeground as a float, for easier usage with the methods that use floats for colors. Defaults to white.
    • layers

      A list of SparseTextMap objects, with each representing a foreground layer.
    • mapping

      protected com.badlogic.gdx.utils.IntIntMap mapping
    • font

      The TextCellFactory that is used to determine font size as well as cell size; must be initialized, usually using TextCellFactory.initBySize(), if this is changed after construction.
    • animationCount

      public int animationCount
      Deprecated.
      Use hasActiveAnimations() instead of adjusting this manually
      Will always be 0 unless user code affects it; use hasActiveAnimations() to track animations instead. The approach of tracking animations via a counter was prone to error when multiple effects might remove a Glyph or adjust the animationCount in one direction but not the other. This could result in never-ending phases of a game where input wasn't handled because animationCount was greater than 0, but whatever effect was supposed to reduce animationCount would never happen.
    • glyphs

      A list of individually-movable Glyph objects. This field is public, and though it shouldn't be assigned null (you don't really need to be told that), there may be cases where you may need manual control over what Glyph objects should be added or removed from this SparseLayers.
    • scc

      public IColorCenter<com.badlogic.gdx.graphics.Color> scc
      An IColorCenter to affect color caching and filtering; usually a SquidColorCenter, which can be easily obtained via DefaultResources.getSCC().
  • Constructor Details

  • Method Details

    • getLayerCount

      public int getLayerCount()
      Gets the number of layers currently used in this SparseLayers; if a layer is put into that is equal to or greater than this layer count, then a new layer is created to hold the latest placement. It is recommended that you assign to the layer equal to the result of this method if you want to add a layer. You can add to layers that are higher than this result, and can technically do so out of order, but this just gets confusing because their ordering won't be related to the numbers of the layers.
      Returns:
      the current number of layers in this SparseLayers
    • getLayer

      public SparseTextMap getLayer​(int layer)
      Gets the layer, as a SparseTextMap, that is associated with the given int. If none is associated, this returns null. The associating number does not necessarily have to be less than the number of layers in this SparseLayers. Returns a direct reference to the SparseTextMap layer.
      Parameters:
      layer - the int that is associated with a layer, usually the int used to add to that layer.
      Returns:
      the SparseTextMap layer associated with the given int
    • setLayer

      public void setLayer​(int layerNumber, SparseTextMap contents)
      Sets the SparseTextMap associated with the given layerNumber to the given contents. If layerNumber is too high to set an existing layer, this will add contents as a new layer on top of the others.
      Parameters:
      layerNumber - must be 0 or greater
      contents - a SparseTextMap, possibly obtained with getLayer(int)
    • findLayer

      public int findLayer​(SparseTextMap layerMap)
      Finds the layer number associated with layerMap, or -1 if the given SparseTextMap is not in this SparseLayers.
      Parameters:
      layerMap - a SparseTextMap that was likely returned by addLayer()
      Returns:
      the int the layer is associated with, or -1 if it is not in this SparseLayers.
    • addLayer

      Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added. The layer will generally be associated with a layer number equal to the number of layers currently present, and will be rendered over the existing layers. It might not be associated with the same number if layers were added out-of-order or with skips between associations. If you want to add a layer at some alternate layer number (which can be confusing but may be needed for some reason), there is another overload that allows you to specify the association number. If you may have added some layers out of order or skipped some numbers, you can use findLayer(SparseTextMap) on the returned SparseTextMap to get its association number.
      Returns:
      a SparseTextMap that was just added; null if something went wrong
    • addLayer

      public SparseTextMap addLayer​(int association)
      Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added, or returns an existing layer if one is already associated with the given number. 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 to getLayerCount(), which will maintain the order and layer numbers in a sane way, and this is the behavior of the addLayer overload that does not take a parameter.
      Parameters:
      association - the number to associate the layer with; should usually be between 0 and getLayerCount() inclusive
      Returns:
      a SparseTextMap that either was just added or was already associated with the given layer number; null if something went wrong
    • put

      public void put​(int x, int y, char c)
      Puts the character c at (x, y) with the default foreground. Does not change the background.
      Specified by:
      put in interface IPackedColorPanel
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place, using the default foreground color
    • put

      public void put​(int x, int y, ICellVisible cell)
      Puts the ICellVisible cell at the position x,y; does not change the background. If cell.getPackedColor() is 0f, then this does not change the foreground contents either. Does not filter the given colors.
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      cell - an ICellVisible, which is often implemented outside of SquidLib; this uses its char and color.
    • put

      public void put​(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground)
      Puts the given string horizontally with the first character at the given offset. Uses the given color for the text and does not change the background color at all.

      Does not word wrap. Characters that are not renderable (due to being at negative offsets or offsets greater than the grid size) will not be shown but will not cause any malfunctions.

      Specified by:
      put in interface IPackedColorPanel
      Parameters:
      xOffset - the x coordinate of the first character
      yOffset - the y coordinate of the first character
      string - the characters to be displayed
      foreground - the color to use for the text
    • put

      public void put​(int xOffset, int yOffset, IColoredString<? extends com.badlogic.gdx.graphics.Color> cs)
      Puts the given string horizontally with the first character at the given offset, using the colors that cs provides. Does not change the background colors. Does filter the colors from cs if the color center this uses is set up to filter colors.

      Does not word wrap. Characters that are not renderable (due to being at negative offsets or offsets greater than the grid size) will not be shown but will not cause any malfunctions.

      Specified by:
      put in interface IPackedColorPanel
      Parameters:
      xOffset - the x coordinate of the first character
      yOffset - the y coordinate of the first character
      cs - an IColoredString with potentially multiple colors
    • put

      public void put​(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
      Puts the character c at (x, y) with some color. Does not change the background colors.
      Specified by:
      put in interface IPackedColorPanel
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      color - the color to use for c; if null or fully transparent, nothing will change in the foreground
    • put

      public void put​(com.badlogic.gdx.graphics.Color[][] colors)
      Sets the background colors to match the given Color 2D array. If the colors argument is null, does nothing. This will filter each Color in colors if the color center this uses has a filter.
      Parameters:
      colors - the background colors for the given chars
    • put

      public void put​(float[][] colors)
      Sets the background colors to match the given 2D array of colors as packed floats. If the colors argument is null, does nothing. This will not filter the passed colors at all.
      Parameters:
      colors - the background colors to use for this SparseLayers
    • putChars

      public void putChars​(char[][] chars)
      Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0.
      Parameters:
      chars - a 2D char array to place without affecting background colors; these chars will use the default foreground color
    • putChars

      public void putChars​(char[][] chars, float[][] foregrounds)
      Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0. Each char will be drawn in the corresponding foreground color from foregrounds.
      Parameters:
      chars - a 2D char array to place without affecting background colors
      foregrounds - a 2D float array of encoded colors as produced by Color.toFloatBits(); applies to char foregrounds
    • putChars

      public void putChars​(char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds)
      Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0. Each char will be drawn in the corresponding foreground color from foregrounds.
      Parameters:
      chars - a 2D char array to place without affecting background colors
      foregrounds - a 2D array of libGDX colors (any may also be an SColor or other subclass); applies to char foregrounds
    • put

      public 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. If the colors argument is null, does nothing. 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 interface IPackedColorPanel
      Parameters:
      chars - Can be null, indicating that only colors must be put.
      colors - the background colors for the given chars
    • put

      public 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. If the colors argument is null, does nothing. If the chars argument is null, only affects the background colors. This will not filter the passed colors at all.
      Parameters:
      chars - Can be null, indicating that only colors must be put.
      colors - the background colors for the given 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.
      Parameters:
      chars - Can be null, indicating that only colors must be put.
      fgColors - the foreground Colors for the given chars
      bgColors - the background Colors for the given chars
    • put

      public 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. 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.
      Parameters:
      chars - Can be null, indicating that only colors must be put.
      fgColors - the foreground colors for the given chars, as packed floats
      bgColors - the background colors for the given chars, as packed floats
    • gridWidth

      public int gridWidth()
      Specified by:
      gridWidth in interface IPackedColorPanel
      Returns:
      The number of cells that this panel spans, horizontally.
    • gridHeight

      public int gridHeight()
      Specified by:
      gridHeight in interface IPackedColorPanel
      Returns:
      The number of cells that this panel spans, vertically.
    • getGridWidth

      public int getGridWidth()
      The same as gridWidth(); here for compatibility with SquidPanel.
      Returns:
      The number of cells that this panel spans, horizontally.
    • getGridHeight

      public int getGridHeight()
      The same as gridHeight(); here for compatibility with SquidPanel.
      Returns:
      The number of cells that this panel spans, vertically.
    • cellWidth

      public int cellWidth()
      Specified by:
      cellWidth in interface IPackedColorPanel
      Returns:
      The width of a cell, in number of pixels.
    • cellHeight

      public int cellHeight()
      Specified by:
      cellHeight in interface IPackedColorPanel
      Returns:
      The height of a cell, in number of pixels.
    • setTextSize

      public SparseLayers setTextSize​(float wide, float high)
      Changes the width and height of chars the font renders, inside the same cell size. Primarily useful if the font has issues and doesn't line up visually; some older versions of .fnt files distributed with SquidLib had this type of problem (and some may still). Provides compatibility with SquidPanel code.
      Parameters:
      wide - width in approximate pixels
      high - height in approximate pixels
      Returns:
      this for chaining.
    • setDefaultForeground

      public void setDefaultForeground​(com.badlogic.gdx.graphics.Color color)
      Sets the default foreground color. This Color can be null, which will usually not be rendered unless a different color is specified.
      Specified by:
      setDefaultForeground in interface IPackedColorPanel
      Parameters:
      color - a libGDX Color object or an extension of Color, such as SColor
    • getDefaultForegroundColor

      public com.badlogic.gdx.graphics.Color getDefaultForegroundColor()
      Specified by:
      getDefaultForegroundColor in interface IPackedColorPanel
      Returns:
      The default foreground color (if none was set with setDefaultForeground(Color)), or the last color set with setDefaultForeground(Color). This Color can be null which will usually not be rendered unless a different color is specified.
    • setDefaultBackground

      public void setDefaultBackground​(com.badlogic.gdx.graphics.Color color)
      Sets the default background color. This Color can be null, which will usually not be rendered unless a different color is specified.
      Parameters:
      color - a libGDX Color object or an extension of Color, such as SColor
    • getDefaultBackgroundColor

      public com.badlogic.gdx.graphics.Color getDefaultBackgroundColor()
      Returns:
      The default background color (if none was set with setDefaultBackground(Color)), or the last color set with setDefaultBackground(Color). This can be null, which will usually not be rendered unless a different color is specified.
    • setColorCenter

      protected void setColorCenter​(IColorCenter<com.badlogic.gdx.graphics.Color> icc)
      Method to change the backing IColorCenter. Note that the IColorCenter is not used to filter floats that encode colors, so passing the result of Color.toFloatBits() can be used to bypass the filtering if you want a color to be used exactly.
      Parameters:
      icc - an IColorCenter that can cache and possibly filter Color objects
    • getColorCenter

      public IColorCenter<com.badlogic.gdx.graphics.Color> getColorCenter()
      Gets the IColorCenter this can use to filter Color objects; this is usually a SquidColorCenter. Note that the IColorCenter is not used to filter floats that encode colors, so passing the result of Color.toFloatBits() can be used to bypass the filtering if you want a color to be used exactly.
      Returns:
      the IColorCenter this uses
    • 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 with setColorCenter(IColorCenter).
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      foreground - the color to use for c; if null or fully transparent, nothing will change in the foreground
      background - 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, ICellVisible cell, float background)
      Puts the ICellVisible cell at the position x,y with the given background color as an encoded float, such as those produced by Color.toFloatBits(). If cell.getPackedColor() 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.
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      cell - an ICellVisible, which is often implemented outside of SquidLib; this uses its char and color.
      background - 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, 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 by Color.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.
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      foreground - the color to use for c; if 0f, nothing will change in the foreground
      background - 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, float foreground)
      Puts the char c at the position x,y with the given foreground color as an encoded float (the kind produced by Color.toFloatBits()). If foreground is 0f, then this does nothing. Does not filter the given color.
      Specified by:
      put in interface IPackedColorPanel
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      foreground - the color to use for c; if 0f, this call does nothing
    • 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 with 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 to getLayerCount(), which will maintain the order and layer numbers in a sane way.
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      foreground - the color to use for c; if null or fully transparent, nothing will change in the foreground
      background - the color to use for the cell; if null or fully transparent, nothing will change in the background
      layer - the layer to place the colorful char into; should usually be between 0 and getLayerCount() inclusive
    • put

      public 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 by Color.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 to getLayerCount(), which will maintain the order and layer numbers in a sane way.
      Parameters:
      x - the x position to place the char at
      y - the y position to place the char at
      c - the char to place
      foreground - the color to use for c; if 0f, nothing will change in the foreground
      background - the color to use for the cell; if null or fully transparent, nothing will change in the background
      layer - the layer to place the colorful char into; should usually be between 0 and 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 with setColorCenter(IColorCenter).
      Parameters:
      x - the x position to place the String at
      y - the y position to place the String at
      text - the String to place
      foreground - the color to use for text; if null or fully transparent, nothing will change in the foreground
      background - 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, 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 by Color.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.
      Parameters:
      x - the x position to place the String at
      y - the y position to place the String at
      text - the String to place
      foreground - the color to use for text; if 0f, nothing will change in the foreground
      background - 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 with 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 to getLayerCount(), which will maintain the order and layer numbers in a sane way.
      Parameters:
      x - the x position to place the String at
      y - the y position to place the String at
      text - the String to place
      foreground - the color to use for text; if null or fully transparent, nothing will change in the foreground
      background - the color to use for the cells; if null or fully transparent, nothing will change in the background
      layer - the layer to place the colorful char into; should usually be between 0 and getLayerCount() inclusive
    • put

      public 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 by Color.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 to getLayerCount(), which will maintain the order and layer numbers in a sane way.
      Parameters:
      x - the x position to place the String at
      y - the y position to place the String at
      text - the String to place
      foreground - the color to use for text; if 0f, nothing will change in the foreground
      background - the color to use for the cells; if null or fully transparent, nothing will change in the background
      layer - the layer to place the colorful char into; should usually be between 0 and getLayerCount() inclusive
    • put

      public void put​(int x, int y, com.badlogic.gdx.graphics.Color color)
      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 interface IPackedColorPanel
      Parameters:
      x - where to change the background color, x-coordinate
      y - where to change the background color, y-coordinate
      color - the Color to change to; if null will be considered fully transparent
    • put

      public void put​(int x, int y, float color)
      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 interface IPackedColorPanel
      Parameters:
      x - where to change the background color, x-coordinate
      y - where to change the background color, y-coordinate
      color - 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
    • putWithLight

      public void putWithLight​(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - a double 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 more
    • putWithLight

      public void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
    • putWithLight

      public void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)
      A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - a double 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 more
    • putWithConsistentLight

      public void putWithConsistentLight​(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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
    • 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
      flickerSpeed - a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
    • calculateConsistentLightModifier

      Gets a modifier that should be given to calculateConsistentLightAmount(float, float); this only needs to be called at most once per frame. It uses a flickerSpeed of 0.0015f, if you want to compare it to calculateConsistentLightModifier(float).
      Returns:
      a modifier to pass to calculateConsistentLightAmount(float, float)
    • calculateConsistentLightModifier

      public float calculateConsistentLightModifier​(float flickerSpeed)
      Gets a modifier that should be given to calculateConsistentLightAmount(float, float); this only needs to be called at most once per frame. It uses the given flickerSpeed; a common example value is 0.0015f.
      Returns:
      a modifier to pass to calculateConsistentLightAmount(float, float)
    • calculateConsistentLightAmount

      public float calculateConsistentLightAmount​(float lightAmount, float modifier)
      Allows you to reproduce the effects of putWithConsistentLight(int, int, char, float, float, float, double, float) without recalculating the modifier many times per frame. You should typically calculate the modifier once per frame using calculateConsistentLightModifier(). This method should usually be called once per cell that needs consistent lighting that flickers the same in all directions.
      Parameters:
      lightAmount - typically from FOV or some other way of generating a float with lower values further from a position (such as a light)
      modifier - calculated previously by calculateConsistentLightModifier(), which should be done per-frame
      Returns:
      the adjusted light amount to mimic the appearance of putWithConsistentLight(int, int, char, float, float, float, double, float)
    • putWithConsistentLight

      public void putWithConsistentLight​(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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
    • 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
      flickerSpeed - 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, char c, float foreground, 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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
    • putWithConsistentLight

      public void putWithConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, double 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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - a double 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 more
    • putWithConsistentLight

      public void putWithConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, double 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
      flickerSpeed - a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
    • putWithReverseConsistentLight

      public void putWithReverseConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
      A convenience method that handles blending the foreground 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 and placed the background as-is. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a packed float color
      background - the "base" color to use for the background, which will used without modification, as a packed float color
      lightColor - the color to mix with the foreground, as a packed float color
      lightAmount - a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
    • putWithReverseConsistentLight

      public void putWithReverseConsistentLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, float flickerSpeed)
      A convenience method that handles blending the foreground 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 and placed the background as-is. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a packed float color
      background - the "base" color to use for the background, which will used without modification, as a packed float color
      lightColor - the color to mix with the foreground, as a packed float color
      lightAmount - a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
      flickerSpeed - 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, char c, com.badlogic.gdx.graphics.Color foreground, 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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Color
      background - the "base" color to use for the background, which will used without modification
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
    • putWithConsistentLight

      public void putWithConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will used without modification
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
      flickerSpeed - a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
    • putWithReverseConsistentLight

      public void putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it from putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Identical to calling putWithReverseConsistentLight(int, int, char, Color, Color, Color, float, float) with 0.0015f as the last parameter.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Color
      background - the "base" color to use for the background, which will used without modification
      lightColor - the color to mix with the foreground, as a libGDX Color
      lightAmount - a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
    • putWithReverseConsistentLight

      public void putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Color
      background - the "base" color to use for the background, which will used without modification
      lightColor - the color to mix with the foreground, as a libGDX Color
      lightAmount - a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
      flickerSpeed - a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
    • putWithReverseConsistentLight

      public void putWithReverseConsistentLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double 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 putWithLight(int, int, float, float, float, Noise.Noise3D), which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib's FOV 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to draw; may be '\0' to draw a solid block
      foreground - the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Color
      background - the "base" color to use for the background, which will used without modification
      lightColor - the color to mix with the foreground, as a libGDX Color
      lightAmount - a double that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
      flickerSpeed - a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
    • putWithLight

      public 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - 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 more
    • putWithLight

      public void putWithLight​(int x, int y, float background, float lightColor, double 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.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - a double 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 more
    • putWithLight

      public void putWithLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
      A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - 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 more
    • putWithLight

      public void putWithLight​(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
      A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - a double 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 more
    • putWithReverseLight

      public void putWithReverseLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
      A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - 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 more
    • putWithReverseLight

      public void putWithReverseLight​(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
      A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float
      lightColor - the color to mix with the background, as a packed float
      lightAmount - a double 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 more
    • putWithLight

      public void putWithLight​(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
      A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. If flicker is null, this will default to using WhirlingNoise. You can make the lighting dimmer by using a darker color for lightColor or by giving a lower value for lightAmount.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
      flicker - a Noise.Noise3D instance, such as WhirlingNoise.instance; may be null to use WhirlingNoise
    • putWithLight

      public void putWithLight​(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
      A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. If flicker is null, this will default to using WhirlingNoise. You can make the lighting dimmer by using a darker color for lightColor or by giving a lower value for lightAmount.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a libGDX Color
      lightColor - the color to mix with the background, as a libGDX Color
      lightAmount - 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 more
      flicker - a Noise.Noise3D instance, such as WhirlingNoise.instance; may be null to use WhirlingNoise
    • putWithLight

      public void putWithLight​(int x, int y, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
      A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. If flicker is null, this will default to using WhirlingNoise. You can make the lighting dimmer by using a darker color for lightColor or by giving a lower value for lightAmount.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
      flicker - a Noise.Noise3D instance, such as WhirlingNoise.instance; may be null to use WhirlingNoise
    • putWithLight

      public void putWithLight​(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
      A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the given Noise.Noise3D object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. If flicker is null, this will default to using WhirlingNoise. You can make the lighting dimmer by using a darker color for lightColor or by giving a lower value for lightAmount.
      Parameters:
      x - the x position, in cells
      y - the y position, in cells
      c - the char to put in the foreground
      foreground - the color to use for the foreground, as a packed float; if 0f, this won't place a foreground char
      background - the "base" color to use for the background, which will be combined with lightColor, as a packed float color
      lightColor - the color to mix with the background, as a packed float color
      lightAmount - 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 more
      flicker - a Noise.Noise3D instance, such as WhirlingNoise.instance; may be null to use WhirlingNoise
    • putBorders

      public void putBorders​(float color, String caption)
    • putBordersCaptioned

      public void putBordersCaptioned​(float color, IColoredString<com.badlogic.gdx.graphics.Color> caption)
      Parameters:
      color - the color to draw the borders with; does not affect caption's color(s)
      caption - an IColoredString
    • clear

      public void clear​(int x, int y)
      Removes the foreground chars, where present, in all layers at the given x,y position. The backgrounds will be unchanged.
      Specified by:
      clear in interface IPackedColorPanel
      Parameters:
      x - the x-coordinate of the position to remove all chars from
      y - the y-coordinate of the position to remove all chars from
    • clear

      public void clear​(int x, int y, int layer)
      Removes the foreground char, if present, in the given layer at the given x,y position. The backgrounds and other layers will be unchanged.
      Parameters:
      x - the x-coordinate of the position to remove all chars from
      y - the y-coordinate of the position to remove all chars from
      layer - the layer to remove from
    • clear

      public void clear()
      Removes all background colors, setting them to transparent, and all foreground chars in all layers.
      Overrides:
      clear in class com.badlogic.gdx.scenes.scene2d.Actor
    • clear

      public void clear​(int layer)
      Removes all foreground chars in the requested layer; does not affect the background or other layers.
    • fillBackground

      public void fillBackground​(com.badlogic.gdx.graphics.Color color)
      Fills all of the background with the given color as libGDX Color object.
      Parameters:
      color - the color to use for all of the background, as a libGDX Color or some subclass like SColor
    • fillBackground

      public void fillBackground​(float color)
      Fills all of the background with the given color as a packed float.
      Parameters:
      color - the color to use for all of the background, as a packed float
    • fillArea

      public 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.).
      Parameters:
      color - a libGDX Color to fill the area with; may be null to make the background transparent
      x - left edge's x coordinate, in cells
      y - top edge's y coordinate, in cells
      width - the width of the area to change the color on
      height - the height of the area to change the color on
    • fillArea

      public 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.
      Parameters:
      color - a color as a packed float to fill the area with; may be 0f to make the background transparent
      x - left edge's x coordinate, in cells
      y - top edge's y coordinate, in cells
      width - the width of the area to change the color on
      height - the height of the area to change the color on
    • hasActiveAnimations

      public boolean hasActiveAnimations()
      Gets whether any animations or other scene2d Actions are running on this SparseLayers.
      Specified by:
      hasActiveAnimations in interface IPackedColorPanel
      Returns:
      true if any animations or Actions are currently running, false otherwise
    • getBackgrounds

      public float[][] getBackgrounds()
      Gets a direct reference to the 2D float array this uses for background colors.
      Returns:
      a direct reference to the 2D float array this uses for background colors.
    • setBackgrounds

      public void setBackgrounds​(float[][] backgrounds)
      Changes the reference this uses for the float array for background colors; this will not accept null parameters, nor will it accept any 2D array with dimensions that do not match the (unchanging) gridWidth and gridHeight of this SparseLayers.
      Parameters:
      backgrounds - a non-null 2D float array of colors; must have width == gridWidth and height == gridHeight
    • getFont

      Gets a direct reference to the TextCellFactory this uses to draw and size its text items and cells.
      Returns:
      a direct reference to the TextCellFactory this uses to draw and size its text items and cells.
    • setFont

      public void setFont​(TextCellFactory font)
      Sets the TextCellFactory this uses to draw and size its text items and cells. The given TextCellFactory must not be null. If font is uninitialized, this will initialize it using cellWidth and cellHeight. If font has been initialized with a different height and width, then the sizing of this SparseLayers will change.
      Parameters:
      font - a non-null TextCellFactory; if uninitialized, this will initialize it using cellWidth and cellHeight.
    • getScc

      public IColorCenter<com.badlogic.gdx.graphics.Color> getScc()
      Gets the IColorCenter for Color objects (almost always a SquidColorCenter, but this isn't guaranteed) that this uses to cache and possibly alter Colors that given to it as parameters.
      Returns:
      the IColorCenter of Color that this uses to cache and modify Colors given to it
    • setScc

      public void setScc​(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
      Sets the IColorCenter for Color objects that this uses to cache and modify Colors given to it; does not accept null parameters.
      Parameters:
      scc - a non-null IColorCenter of Color that this will use to cache and modify Colors given to it
    • worldX

      public float worldX​(int gridX)
      Used internally to go between grid positions and world positions.
      Parameters:
      gridX - x on the grid
      Returns:
      x in the world
    • worldY

      public float worldY​(int gridY)
      Used internally to go between grid positions and world positions.
      Parameters:
      gridY - y on the grid
      Returns:
      y in the world
    • gridX

      public int gridX​(float worldX)
      Used internally to go between world positions and grid positions.
      Parameters:
      worldX - x in the world
      Returns:
      x on the grid
    • gridY

      public int gridY​(float worldY)
      Used internally to go between world positions and grid positions.
      Parameters:
      worldY - y in the world
      Returns:
      y on the grid
    • blend

      public void blend​(int x, int y, float color, float mixBy)
      Using the existing background color at the 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).
      Specified by:
      blend in interface IPackedColorPanel
      Parameters:
      x - the x component of the position in this panel to draw the starting color from
      y - the y component of the position in this panel to draw the starting color from
      color - the new color to mix with the starting color; a packed float, as made by Color.toFloatBits()
      mixBy - the amount by which the new color will affect the old one, between 0 (no effect) and 1 (overwrite)
    • glyph

      public TextCellFactory.Glyph glyph​(char shown, com.badlogic.gdx.graphics.Color color, int x, int y)
      Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes a char to show, a color that may be filtered, and an x,y position in grid cells, and returns a Glyph that has those qualities set.
      Parameters:
      shown - the char to use in the Glyph
      color - the color to use for the Glyph, which can be filtered
      x - the x position, in grid cells
      y - the y position, in grid cells
      Returns:
      a Glyph (an inner class of TextCellFactory) with the given qualities
    • glyph

      public TextCellFactory.Glyph glyph​(char shown, float color, int x, int y)
      Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes a char to show, a color as an encoded float, and an x,y position in grid cells, and returns a Glyph that has those qualities set.
      Parameters:
      shown - the char to use in the Glyph
      color - the color to use for the Glyph as an encoded float
      x - the x position, in grid cells
      y - the y position, in grid cells
      Returns:
      a Glyph (an inner class of TextCellFactory) with the given qualities
    • glyphFromGrid

      public TextCellFactory.Glyph glyphFromGrid​(int x, int y)
      "Promotes" a colorful char in the first layer to a Glyph that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes only an x,y position in grid cells, removes the char at that position in the first layer from normal rendering, and returns a Glyph at that same position with the same char and color, but that can be moved more.
      Parameters:
      x - the x position, in grid cells
      y - the y position, in grid cells
      Returns:
      a Glyph (an inner class of TextCellFactory) that took the qualities of the removed char and its color
    • glyphFromGrid

      public TextCellFactory.Glyph glyphFromGrid​(int x, int y, int layer)
      "Promotes" a colorful char in the given layer to a Glyph that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes only an x,y position in grid cells, removes the char at that position in the given layer from normal rendering, and returns a Glyph at that same position with the same char and color, but that can be moved more.
      Parameters:
      x - the x position, in grid cells
      y - the y position, in grid cells
      layer - the layer to take a colorful char from
      Returns:
      a Glyph (an inner class of TextCellFactory) that took the qualities of the removed char and its color; may return null if the layer is invalid
    • recallToGrid

      public void recallToGrid​(TextCellFactory.Glyph glyph)
      Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the first layer with the Glyph's char and color.
      Parameters:
      glyph - the Glyph to remove and fit back into the grid
    • recallToGrid

      public void recallToGrid​(TextCellFactory.Glyph glyph, int layer)
      Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the given layer with the Glyph's char and color.
      Parameters:
      glyph - the Glyph to remove and fit back into the grid
    • removeGlyph

      public void removeGlyph​(TextCellFactory.Glyph glyph)
      A way to remove a Glyph from the group of glyphs this renders, while also ending any animations or other Actions that the removed Glyph was scheduled to perform.
      Parameters:
      glyph - a Glyph that should be removed from the glyphs List this holds
    • bump

      public void bump​(TextCellFactory.Glyph glyph, Direction direction, float duration)
      Start a bumping animation in the given direction that will last duration seconds.
      Parameters:
      glyph - A TextCellFactory.Glyph, probably produced by glyph(char, float, int, int) or glyphFromGrid(int, int)
      direction - the direction for the glyph to bump towards
      duration - a float, measured in seconds, for how long the animation should last; commonly 0.12f
    • bump

      public void bump​(float delay, TextCellFactory.Glyph glyph, Direction direction, float duration, Runnable postRunnable)
      Start a bumping animation in the given direction after delay seconds, that will last duration seconds; runs postRunnable after the duration completes if postRunnable is non-null.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      glyph - A TextCellFactory.Glyph, which should be produced by a SparseLayers method like glyph(char, float, int, int) or glyphFromGrid(int, int)
      direction - the direction for the glyph to bump towards
      duration - a float, measured in seconds, for how long the animation should last; commonly 0.12f
      postRunnable - a Runnable to execute after the bump completes; may be null to do nothing.
    • slide

      public void slide​(TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
      Slides glyph from (xstartX,startY) to (newx, newy). Takes a number of seconds equal to duration to complete. This also allows a Runnable to be given as postRunnable to be run after the slide completes, or null to not run anything after the slide.
      Parameters:
      glyph - A TextCellFactory.Glyph, probably produced by glyph(char, float, int, int) or glyphFromGrid(int, int)
      startX - Where to start the slide, horizontally.
      startY - Where to start the slide, vertically.
      newX - Where to end the slide, horizontally.
      newY - Where to end the slide, vertically.
      duration - The animation's duration.
      postRunnable - a Runnable to execute after the slide completes; may be null to do nothing.
    • slide

      public void slide​(float delay, TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
      Slides glyph from (xstartX,startY) to (newx, newy) after waiting delay seconds. Takes a number of seconds equal to duration to complete (starting after the delay). This also allows a Runnable to be given as postRunnable to be run after the slide completes, or null to not run anything after the slide.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      glyph - A TextCellFactory.Glyph, probably produced by glyph(char, float, int, int) or glyphFromGrid(int, int)
      startX - Where to start the slide, horizontally.
      startY - Where to start the slide, vertically.
      newX - Where to end the slide, horizontally.
      newY - Where to end the slide, vertically.
      duration - The animation's duration.
      postRunnable - a Runnable to execute after the slide completes; may be null to do nothing.
    • wiggle

      public void wiggle​(TextCellFactory.Glyph glyph, float duration)
      Starts an wiggling animation for the object at the given location for the given duration in seconds.
      Parameters:
      glyph - A TextCellFactory.Glyph, probably produced by glyph(char, float, int, int) or glyphFromGrid(int, int)
      duration - in seconds, as a float
    • wiggle

      public void wiggle​(float delay, TextCellFactory.Glyph glyph, float duration, Runnable postRunnable)
      Starts a wiggling animation for the object at the given location, after waiting delay seconds, for the given duration in seconds; runs postRunnable afterwards if it is non-null.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      glyph - A TextCellFactory.Glyph, probably produced by glyph(char, float, int, int) or glyphFromGrid(int, int)
      duration - in seconds, as a float
      postRunnable - a Runnable to execute after the wiggle completes; may be null to do nothing.
    • tint

      public void tint​(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
      Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      color - what to transition the cell's color towards, and then transition back from, as a Color object
      duration - how long the total "round-trip" transition should take in seconds
    • tint

      public void tint​(int x, int y, float encodedColor, float duration)
      Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
    • tint

      public void tint​(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
      Tints the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueue postRunnable for running after the created action ends.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
      postRunnable - a Runnable to execute after the tint completes; may be null to do nothing.
    • tint

      public void tint​(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
      Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
      The SquidPanel.tint(float, int, int, Color, float, Runnable) method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      color - what to transition the cell's color towards, and then transition back from, as a Color object
      duration - how long the total "round-trip" transition should take in seconds
    • tint

      public void tint​(int x, int y, int layer, float encodedColor, float duration)
      Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
      The SquidPanel.tint(float, int, int, Color, float, Runnable) method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
    • tint

      public void tint​(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
      Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueue postRunnable for running after the created action ends.
      The SquidPanel.tint(float, int, int, Color, float, Runnable) method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
      This will only behave correctly if you call Stage.act() before you call Stage.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.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to tint
      y - the y-coordinate of the cell to tint
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
      postRunnable - a Runnable to execute after the tint completes; may be null to do nothing.
    • tint

      public void tint​(TextCellFactory.Glyph glyph, float encodedColor, float duration)
      Tints the given glyph (which may or may not be part of the glyphs list this holds) so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds. This resets the glyph to its pre-tint color before it ends.
      Parameters:
      glyph - the TextCellFactory.Glyph to tint
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
    • tint

      public void tint​(float delay, TextCellFactory.Glyph glyph, float encodedColor, float duration, Runnable postRunnable)
      Tints the given glyph (which may or may not be part of the glyphs list this holds) so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueue postRunnable for running after the created action ends. This resets the glyph to its pre-tint color before it runs any postRunnable.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      glyph - the TextCellFactory.Glyph to tint
      encodedColor - what to transition the cell's color towards, and then transition back from, as a packed float
      duration - how long the total "round-trip" transition should take in seconds
      postRunnable - a Runnable to execute after the tint completes; may be null to do nothing.
    • summon

      public void summon​(int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration)
      Create a new Glyph at (startX, startY) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Glyph.
      Unlike SquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float), this does not rotate the Glyph it produces.
      Parameters:
      startX - the starting x position in cells
      startY - the starting y position in cells
      endX - the ending x position in cells
      endY - the ending y position in cells
      shown - the char to show (the same char throughout the effect)
      startColor - the starting Color
      endColor - the Color to transition to
      duration - the duration in seconds for the effect
    • summon

      public void summon​(float delay, int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
      Create a new Glyph at (startX, startY) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
      Unlike SquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float), this does not rotate the Glyph it produces.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      startX - the starting x position in cells
      startY - the starting y position in cells
      endX - the ending x position in cells
      endY - the ending y position in cells
      shown - the char to show (the same char throughout the effect)
      startColor - the starting Color
      endColor - the Color to transition to
      duration - the duration in seconds for the effect
      postRunnable - a Runnable to execute after the summon completes; may be null to do nothing.
    • summon

      public void summon​(float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration)
      Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before removing the Glyph.
      Unlike SquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float), this does not rotate the Glyph it produces.
      Parameters:
      startX - the starting x position in world coordinates
      startY - the starting y position in world coordinates
      endX - the ending x position in world coordinates
      endY - the ending y position in world coordinates
      shown - the char to show (the same char throughout the effect)
      startColor - the starting Color
      endColor - the Color to transition to
      duration - the duration in seconds for the effect
    • summon

      public void summon​(float delay, float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
      Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
      Unlike SquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float), this does not rotate the Glyph it produces.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      startX - the starting x position in world coordinates
      startY - the starting y position in world coordinates
      endX - the ending x position in world coordinates
      endY - the ending y position in world coordinates
      shown - the char to show (the same char throughout the effect)
      startColor - the starting Color
      endColor - the Color to transition to
      duration - the duration in seconds for the effect
      postRunnable - a Runnable to execute after the summon completes; may be null to do nothing.
    • burst

      public void burst​(int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration)
      Convenience method to produce an explosion, splash, or burst effect. Calls summon(int, int, int, int, char, float, float, float) repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square.
      Unlike SquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float), this does not rotate the individual Glyphs it produces.
      Parameters:
      x - the starting, center, x-position in cells to create all Actors at
      y - the starting, center, y-position in cells to create all Actors at
      distance - how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)
      measurement - a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will take
      shown - the char to use for Glyphs; should definitely be visible
      startColor - the encoded color to start the effect with
      endColor - the encoded color to end the effect on
      duration - how long, in seconds, the effect should last
    • burst

      public void burst​(float delay, int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
      Convenience method to produce an explosion, splash, or burst effect. Calls summon(float, int, int, int, int, char, float, float, float, Runnable) repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square. This takes a delay in seconds that can be used to make the effect wait to start for some amount of time, and a Runnable that will be run once after the burst's full duration completes (not once per summoned Glyph).
      Unlike SquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float), this does not rotate the individual Glyphs it produces.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the starting, center, x-position in cells to create all Actors at
      y - the starting, center, y-position in cells to create all Actors at
      distance - how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)
      measurement - a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will take
      shown - the char to use for Glyphs; should definitely be visible
      startColor - the encoded color to start the effect with
      endColor - the encoded color to end the effect on
      duration - how long, in seconds, the effect should last
      postRunnable - a Runnable to execute after the burst completes; may be null to do nothing, and will only be run once for the whole burst effect.
    • burst

      public void burst​(int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration)
      Convenience method to produce an explosion, splash, or burst effect. Calls summon(int, int, int, int, char, float, float, float) repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square.
      Unlike SquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float), this does not rotate the individual Glyphs it produces.
      Parameters:
      x - the starting, center, x-position in cells to create all Actors at
      y - the starting, center, y-position in cells to create all Actors at
      distance - how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)
      measurement - a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will take
      choices - a String or other CharSequence containing the chars this can randomly choose
      startColor - the encoded color to start the effect with
      endColor - the encoded color to end the effect on
      duration - how long, in seconds, the effect should last
    • burst

      public void burst​(float delay, int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration, Runnable postRunnable)
      Convenience method to produce an explosion, splash, or burst effect. Calls summon(int, int, int, int, char, float, float, float) repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square. This takes a delay in seconds that can be used to make the effect wait to start for some amount of time, and a Runnable that will be run once after the burst's full duration completes (not once per summoned Glyph).
      Unlike SquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float), this does not rotate the individual Glyphs it produces.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the starting, center, x-position in cells to create all Actors at
      y - the starting, center, y-position in cells to create all Actors at
      distance - how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)
      measurement - a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will take
      choices - a String or other CharSequence containing the chars this can randomly choose
      startColor - the encoded color to start the effect with
      endColor - the encoded color to end the effect on
      duration - how long, in seconds, the effect should last
      postRunnable - a Runnable to execute after the burst completes; may be null to do nothing, and will only be run once for the whole burst effect.
    • recolor

      public void recolor​(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
      Changes the background at position x,y so it becomes the given color, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      color - what to gradually change the cell's color to, as a Color object
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(int x, int y, float encodedColor, float duration)
      Changes the background at position x,y so it becomes the given encodedColor, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(float delay, int x, int y, float encodedColor, float duration)
      Changes the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
      Changes the background at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds. The background will keep the changed color after the effect, unless drawn over. Additionally, enqueue postRunnable for running after the created action ends.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
      postRunnable - a Runnable to execute after the recolor completes; may be null to do nothing.
    • recolor

      public void recolor​(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
      Changes the foreground in the given layer at position x,y so it becomes the given color, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      color - what to gradually change the cell's color to, as a Color object
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(int x, int y, int layer, float encodedColor, float duration)
      Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(float delay, int x, int y, int layer, float encodedColor, float duration)
      Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
    • recolor

      public void recolor​(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
      Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting for delay (in seconds) before performing it, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over. Additionally, enqueue postRunnable for running after the created action ends.
      This will only behave correctly if you call Stage.act() before you call Stage.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 recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.
      Parameters:
      delay - how long to wait in seconds before starting the effect
      x - the x-coordinate of the cell to recolor
      y - the y-coordinate of the cell to recolor
      layer - which layer to affect; if you haven't specified a layer when placing text, then this should be 0
      encodedColor - what to gradually change the cell's color to, as a packed float
      duration - how long the total transition should take in seconds
      postRunnable - a Runnable to execute after the recolor completes; may be null to do nothing.
    • draw

      public void draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
      Draws the SparseLayers and all glyphs it tracks. Batch.begin() must have already been called on the batch, and Batch.end() should be called after this returns and before the rendering code finishes for the frame.
      This will set the shader of batch 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 class com.badlogic.gdx.scenes.scene2d.Actor
      Parameters:
      batch - a Batch such as a FilterBatch that must be between a begin() and end() call; usually done by Stage
      parentAlpha - currently ignored