Class ColorChangeImage

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Image
squidpony.squidgrid.gui.gdx.ColorChangeImage
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout

public class ColorChangeImage
extends com.badlogic.gdx.scenes.scene2d.ui.Image
An Image that has multiple possible color tints that it cycles through over time. Created by Tommy Ettinger on 3/23/2016.
  • Constructor Summary

    Constructors 
    Constructor Description
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, float width, float height, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, float width, float height, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, float width, float height, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, float width, float height, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, com.badlogic.gdx.graphics.Color... colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
    ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, List<com.badlogic.gdx.graphics.Color> colors)
    Creates an image stretched and aligned center, that will use the specified list of colors.
  • Method Summary

    Modifier and Type Method Description
    void act​(float delta)
    Updates the actor based on time.
    com.badlogic.gdx.graphics.Color getColor()
    Returns the color the actor will be tinted when drawn.
    void resetLoopTime​(float loopTime)
    Changes the amount of time this takes to loop through all colors, and also resets the current loop to its start.
    void setColors​(com.badlogic.gdx.graphics.Color... colors)
    Sets the list of colors this uses to choose what color it draws with.
    void setColors​(List<com.badlogic.gdx.graphics.Color> colors)
    Sets the list of colors this uses to choose what color it draws with.

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Image

    draw, getAlign, getDrawable, getImageHeight, getImageWidth, getImageX, getImageY, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, layout, setAlign, setDrawable, setDrawable, setScaling, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget

    getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, 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, stageToLocalCoordinates, toBack, toFront

    Methods inherited from class java.lang.Object

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

    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, float width, float height, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.Texture texture, float loopTime, boolean doubleWidth, float width, float height, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, float width, float height, List<com.badlogic.gdx.graphics.Color> colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • ColorChangeImage

      public ColorChangeImage​(com.badlogic.gdx.graphics.g2d.TextureRegion texture, float loopTime, boolean doubleWidth, float width, float height, com.badlogic.gdx.graphics.Color... colors)
      Creates an image stretched and aligned center, that will use the specified list of colors.
      Parameters:
      texture - the texture to use
      loopTime - the amount of time, in seconds, to spend transitioning through the colors before repeating
      doubleWidth - true if this takes up two grid cells; only matters if you use AnimatedEntity.setDirection(Direction)
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
  • Method Details

    • getColor

      public com.badlogic.gdx.graphics.Color getColor()
      Returns the color the actor will be tinted when drawn. Takes the Color from the List of Color this was constructed with or assigned with setColors, not the normal Actor color assigned with setColor.
      Overrides:
      getColor in class com.badlogic.gdx.scenes.scene2d.Actor
      Returns:
      the Color this will be drawn with
    • setColors

      public void setColors​(List<com.badlogic.gdx.graphics.Color> colors)
      Sets the list of colors this uses to choose what color it draws with.
      Parameters:
      colors - a List of Color, such as one returned by SquidColorCenter's gradient or rainbow methods
    • setColors

      public void setColors​(com.badlogic.gdx.graphics.Color... colors)
      Sets the list of colors this uses to choose what color it draws with.
      Parameters:
      colors - an array or vararg of Color
    • act

      public void act​(float delta)
      Updates the actor based on time. Typically this is called each frame by Stage.act(float).

      The default implementation calls Action.act(float) on each action and removes actions that are complete.

      Overrides:
      act in class com.badlogic.gdx.scenes.scene2d.Actor
      Parameters:
      delta - Time in seconds since the last frame.
    • resetLoopTime

      public void resetLoopTime​(float loopTime)
      Changes the amount of time this takes to loop through all colors, and also resets the current loop to its start.
      Parameters:
      loopTime - the amount of time, in seconds, it takes to loop through all the colors in the list