Class ImageGraphics

java.lang.Object
ch.epfl.cs107.play.math.Node
ch.epfl.cs107.play.engine.actor.ImageGraphics
All Implemented Interfaces:
Graphics, Attachable, Positionable
Direct Known Subclasses:
Sprite

public class ImageGraphics extends Node implements Graphics
Contains information to render a single image, which can be attached to any positionable.
  • Constructor Details

    • ImageGraphics

      public ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor, float alpha, float depth, boolean removeBackground)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
      roi - (RegionOfInterest): region of interest as a rectangle in the image
      anchor - (Vector): image anchor, not null
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
      depth - (float): render priority, lower-values drawn first
      removeBackground - (boolean): indicate if we need to remove the uniform color background before using this image
    • ImageGraphics

      public ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor, float alpha, float depth)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
      roi - (RegionOfInterest): region of interest as a rectangle in the image
      anchor - (Vector): image anchor, not null
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
      depth - (float): render priority, lower-values drawn first
    • ImageGraphics

      public ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
      roi - (RegionOfInterest): region of interest as a rectangle in the image
      anchor - (Vector): image anchor, not null
    • ImageGraphics

      public ImageGraphics(String name, float width, float height, RegionOfInterest roi)
      Creates a new image graphics. Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
      roi - (RegionOfInterest): region of interest as a rectangle in the image
    • ImageGraphics

      public ImageGraphics(String name, float width, float height, RegionOfInterest roi, boolean removeBackground)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
      roi - (RegionOfInterest): region of interest as a rectangle in the image
      removeBackground - (boolean): indicate if we need to remove the uniform color background before using this image
    • ImageGraphics

      public ImageGraphics(String name, float width, float height)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, may be null
      width - (float): actual image width, before transformation
      height - (float): actual image height, before transformation
  • Method Details

    • setName

      public void setName(String name)
      Sets image name.
      Parameters:
      name - (String): new image name, may be null
    • getName

      public String getName()
      Returns:
      (String): image name, may be null
    • setWidth

      public void setWidth(float width)
      Sets actual image width, before transformation.
      Parameters:
      width - (float): image width
    • getWidth

      public float getWidth()
      Returns:
      (float): actual image width, before transformation
    • setHeight

      public void setHeight(float height)
      Sets actual image height, before transformation.
      Parameters:
      height - (float): image height
    • getHeight

      public float getHeight()
      Returns:
      (float): actual image height, before transformation
    • setAnchor

      public void setAnchor(Vector anchor)
      Sets image anchor location, i.e. where is the center of the image.
      Parameters:
      anchor - (Vector): image anchor, not null
    • getAnchor

      public Vector getAnchor()
      Returns:
      (Vector): image anchor, not null
    • setAlpha

      public void setAlpha(float alpha)
      Sets transparency.
      Parameters:
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
    • getAlpha

      public float getAlpha()
      Returns:
      (float): transparency, between 0 (invisible) and 1 (opaque)
    • setDepth

      public void setDepth(float depth)
      Sets rendering depth.
      Parameters:
      depth - (float): render priority, lower-values drawn first
    • getDepth

      public float getDepth()
      Returns:
      (float): render priority, lower-values drawn first
    • draw

      public void draw(Canvas canvas)
      Description copied from interface: Graphics
      Renders itself on specified canvas.
      Specified by:
      draw in interface Graphics
      Parameters:
      canvas - target, not null