Package ch.epfl.cs107.play.engine.actor
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
Contains information to render a single image, which can be attached to any positionable.
-
Constructor Summary
ConstructorsConstructorDescriptionImageGraphics(String name, float width, float height) Creates a new image graphics.ImageGraphics(String name, float width, float height, RegionOfInterest roi) Creates a new image graphics.ImageGraphics(String name, float width, float height, RegionOfInterest roi, boolean removeBackground) Creates a new image graphics.ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor) Creates a new image graphics.ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor, float alpha, float depth) Creates a new image graphics.ImageGraphics(String name, float width, float height, RegionOfInterest roi, Vector anchor, float alpha, float depth, boolean removeBackground) Creates a new image graphics. -
Method Summary
Modifier and TypeMethodDescriptionvoidRenders itself on specified canvas.floatgetAlpha()floatgetDepth()floatgetName()floatgetWidth()voidsetAlpha(float alpha) Sets transparency.voidSets image anchor location, i.e.voidsetDepth(float depth) Sets rendering depth.voidsetHeight(float height) Sets actual image height, before transformation.voidSets image name.voidsetWidth(float width) Sets actual image width, before transformation.Methods inherited from class ch.epfl.cs107.play.math.Node
getParent, getPosition, getRelativeTransform, getTransform, getVelocity, setParent, setRelativeTransform
-
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 nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformationroi- (RegionOfInterest): region of interest as a rectangle in the imageanchor- (Vector): image anchor, not nullalpha- (float): transparency, between 0 (invisible) and 1 (opaque)depth- (float): render priority, lower-values drawn firstremoveBackground- (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 nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformationroi- (RegionOfInterest): region of interest as a rectangle in the imageanchor- (Vector): image anchor, not nullalpha- (float): transparency, between 0 (invisible) and 1 (opaque)depth- (float): render priority, lower-values drawn first
-
ImageGraphics
Creates a new image graphics.- Parameters:
name- (String): image name, may be nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformationroi- (RegionOfInterest): region of interest as a rectangle in the imageanchor- (Vector): image anchor, not null
-
ImageGraphics
Creates a new image graphics. Creates a new image graphics.- Parameters:
name- (String): image name, may be nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformationroi- (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 nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformationroi- (RegionOfInterest): region of interest as a rectangle in the imageremoveBackground- (boolean): indicate if we need to remove the uniform color background before using this image
-
ImageGraphics
Creates a new image graphics.- Parameters:
name- (String): image name, may be nullwidth- (float): actual image width, before transformationheight- (float): actual image height, before transformation
-
-
Method Details
-
setName
Sets image name.- Parameters:
name- (String): new image name, may be null
-
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
Sets image anchor location, i.e. where is the center of the image.- Parameters:
anchor- (Vector): image anchor, not null
-
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
Description copied from interface:GraphicsRenders itself on specified canvas.
-