Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Texture

[21:7] extends: ImageView

Wraps FXGL's Texture, an ImageView subclass that adds common image-processing operations (subTexture, super-tile composition, grayscale, invert, brighter / darker, transparentColor, blend, outline). Aussom users typically obtain a Texture via fxgl.getAssetLoader().loadTexture(name) in chunk 6; this wrapper exposes direct construction from a JavaFX Image plus the most-used transforms. Because Texture extends ImageView, every wrapper here can be added to a scene through the existing fx.ImageView pattern (via .obj on a compatible Aussom wrapper).

Methods

  • Texture (ImageObj = null)

    Creates a new Texture from a JavaFX Image. Pass null (or nothing) to construct an empty wrapper for adopt to populate; the underlying FXGL Texture constructor requires a non-null Image, so it is only invoked when ImageObj is supplied.

    • @p ImageObj is an Image wrapper (fx.Image), or null.
  • adopt (object Ajo)

    Wraps an existing Texture AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a Texture.
    • @r A new Texture wrapper.
  • getWidth ()

    Returns the width of the underlying image.

    • @r A double with the width.
  • getHeight ()

    Returns the height of the underlying image.

    • @r A double with the height.
  • subTexture (double X, double Y, double W, double H)

    Returns a Texture restricted to the given rectangular region of the source image.

    • @p X is the region X origin.
    • @p Y is the region Y origin.
    • @p W is the region width.
    • @p H is the region height.
    • @r A new Texture wrapper.
  • toGrayscale ()

    Returns a grayscale copy of this texture.

    • @r A new Texture wrapper.
  • brighter ()

    Returns a brighter copy of this texture.

    • @r A new Texture wrapper.
  • darker ()

    Returns a darker copy of this texture.

    • @r A new Texture wrapper.
  • replaceColor (object OldColor, object NewColor)

    Returns a copy of this texture with one color replaced by another.

    • @p OldColor is a Color wrapper for the color to replace.
    • @p NewColor is a Color wrapper for the replacement.
    • @r A new Texture wrapper.
  • transparentColor (object ColorObj)

    Returns a copy of this texture with the given color replaced by transparent pixels.

    • @p ColorObj is a Color wrapper.
    • @r A new Texture wrapper.
  • toAnimatedTexture (int Frames, double DurationSeconds)

    Builds an AnimatedTexture from a sprite-sheet source image by splitting the image horizontally into the requested number of frames and playing each frame for an equal slice of the given duration. The returned wrapper is a Texture (AnimatedTexture extends Texture), so it can be added to a scene the usual way; reach AnimatedTexture-specific methods (play, loop, stop) through its .obj.

    • @p Frames is the number of horizontal cells in the sheet.
    • @p DurationSeconds is the total play duration in seconds.
    • @r A Texture wrapper around an AnimatedTexture.
  • toAnimatedTextureChannel (object ChannelObj)

    Builds an AnimatedTexture from a pre-built AnimationChannel and returns it as a plain Texture wrapper (AnimatedTexture extends Texture). See toAnimatedTexture for the playback-API access pattern.

    • @p ChannelObj is an AnimationChannel wrapper.
    • @r A Texture wrapper around an AnimatedTexture.
  • multiplyColor (object ColorObj)

    Returns a copy of this texture with each pixel's color multiplied (channel-wise) by the given Color.

    • @p ColorObj is a Color wrapper.
    • @r A new Texture wrapper.
  • toColor (object ColorObj)

    Returns a copy of this texture recolored so every non- transparent pixel uses the given Color (preserving alpha).

    • @p ColorObj is a Color wrapper.
    • @r A new Texture wrapper.
  • outline (object ColorObj, int Offset = 1)

    Returns a copy of this texture surrounded by a one- or multi-pixel outline of the given Color.

    • @p ColorObj is a Color wrapper.
    • @p Offset is the outline width in pixels (default 1).
    • @r A new Texture wrapper.
  • discolor ()

    Returns a discolored copy (every pixel becomes white with its original alpha). Useful for tinting effects.

    • @r A new Texture wrapper.
  • toBlackWhite ()

    Returns a high-contrast black-and-white copy.

    • @r A new Texture wrapper.
  • invert ()

    Returns an inverted-color copy.

    • @r A new Texture wrapper.
  • saturate ()

    Returns a more saturated copy.

    • @r A new Texture wrapper.
  • desaturate ()

    Returns a less saturated copy.

    • @r A new Texture wrapper.
  • copy ()

    Returns a copy of this texture. Useful when the same image needs to appear in two scene locations; a JavaFX Node can only have one parent at a time.

    • @r A new Texture wrapper.
  • set (object Other)

    Replaces this texture's image with another texture's image in place.

    • @p Other is a Texture wrapper.
    • @r this object
  • dispose ()

    Releases the texture's image data. Use when many textures have been created at runtime and no longer need to stay in memory.

    • @r this object
  • pixels ()

    Returns a flat list of Pixel objects describing each pixel in the underlying image.

    • @r An AussomJavaObject around a List.
  • superTexture (object Other, string DirectionName)

    Returns a new texture made by concatenating Other onto this texture in the given horizontal or vertical direction.

    • @p Other is a Texture wrapper.
    • @p DirectionName is "RIGHT" / "LEFT" / "UP" / "DOWN". Horizontal directions ("RIGHT", "LEFT") map to javafx.geometry.HorizontalDirection; vertical to VerticalDirection.
    • @r A new Texture wrapper.
  • blend (object BackgroundObj, string BlendModeName)

    Returns a new texture made by blending this texture over the given background using the supplied BlendMode.

    • @p BackgroundObj is a Texture wrapper (or AussomJavaObject around a JavaFX Image).
    • @p BlendModeName is the BlendMode enum name (e.g. "ADD", "MULTIPLY", "SCREEN").
    • @r A new Texture wrapper.