Class ShapeGraphics

java.lang.Object
ch.epfl.cs107.play.math.Node
ch.epfl.cs107.play.engine.actor.ShapeGraphics
All Implemented Interfaces:
Graphics, Attachable, Positionable

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

    • ShapeGraphics

      public ShapeGraphics(Shape shape, Color fillColor, Color outlineColor, float thickness, float alpha, float depth)
      Creates a new shape graphics.
      Parameters:
      shape - (Shape): shape, may be null
      fillColor - (Color): fill color, may be null
      outlineColor - (Color): outline color, may be null
      thickness - (float): outline thickness
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
      depth - (float): render priority, lower-values drawn first
    • ShapeGraphics

      public ShapeGraphics(Shape shape, Color fillColor, Color outlineColor, float thickness)
      Creates a new shape graphics.
      Parameters:
      shape - (Shape): shape, may be null
      fillColor - (Color): fill color, may be null
      outlineColor - (Color): outline color, may be null
      thickness - (float): outline thickness
  • Method Details

    • setShape

      public void setShape(Shape shape)
      Sets shape.
      Parameters:
      shape - (Shape): new shape, may be null
    • getShape

      public Shape getShape()
      Returns:
      (Shape): current shape, may be null
    • setFillColor

      public void setFillColor(Color fillColor)
      Sets fill color.
      Parameters:
      fillColor - (Color): color, may be null
    • getFillColor

      public Color getFillColor()
      Returns:
      (Color): fill color, may be null
    • setOutlineColor

      public void setOutlineColor(Color outlineColor)
      Sets outline color.
      Parameters:
      outlineColor - (Color): color, may be null
    • getOutlineColor

      public Color getOutlineColor()
      Returns:
      (Color): outline color, may be null
    • setThickness

      public void setThickness(float thickness)
      Sets outline thickness.
      Parameters:
      thickness - (float): outline thickness
    • getThickness

      public float getThickness()
      Returns:
      (float): outline thickness
    • 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