Package ch.epfl.cs107.play.engine.actor
Class TextGraphics
java.lang.Object
ch.epfl.cs107.play.math.Node
ch.epfl.cs107.play.engine.actor.TextGraphics
- All Implemented Interfaces:
Graphics,Attachable,Positionable
Contains information to render a single string, which can be attached to any positionable.
-
Constructor Summary
ConstructorsConstructorDescriptionTextGraphics(String text, float fontSize, Color fillColor) Creates a new text graphics.TextGraphics(String text, float fontSize, Color fillColor, Color outlineColor, float thickness, boolean bold, boolean italics, Vector anchor) Creates a new text graphics.TextGraphics(String text, float fontSize, Color fillColor, Color outlineColor, float thickness, boolean bold, boolean italics, Vector anchor, TextAlign.Horizontal hAlign, TextAlign.Vertical vAlign, float alpha, float depth) Creates a new text graphics. -
Method Summary
Modifier and TypeMethodDescriptionvoidRenders itself on specified canvas.floatgetAlpha()floatgetDepth()floatgetText()floatbooleanisBold()booleanvoidsetAlpha(float alpha) Sets transparency.voidSets text anchor, i.e.voidsetBold(boolean bold) Sets bold font.voidsetDepth(float depth) Sets rendering depth.voidsetFillColor(Color fillColor) Sets fill color.voidsetFontName(String fontName) Set the font namevoidsetFontSize(float fontSize) Sets font size.voidsetItalics(boolean italics) Sets italics font.voidsetOutlineColor(Color outlineColor) Sets outline color.voidSets text content.voidsetThickness(float thickness) Sets outline thickness.Methods inherited from class ch.epfl.cs107.play.math.Node
getParent, getPosition, getRelativeTransform, getTransform, getVelocity, setParent, setRelativeTransform
-
Constructor Details
-
TextGraphics
public TextGraphics(String text, float fontSize, Color fillColor, Color outlineColor, float thickness, boolean bold, boolean italics, Vector anchor, TextAlign.Horizontal hAlign, TextAlign.Vertical vAlign, float alpha, float depth) Creates a new text graphics.- Parameters:
text- (String): content, not nullfontSize- (float): sizefillColor- (Color): fill color, may be nulloutlineColor- (Color): outline color, may be nullthickness- (float): outline thicknessbold- (boolean): whether to use bold fontitalics- (boolean): whether to use italics fontanchor- (Vector): text anchorhAlign- (TextAlign.Horizontal): the horizontal alignmentvAlign- (TextAlign.Vertical): the vertical alignmentalpha- (float): transparency, between 0 (invisible) and 1 (opaque)depth- (float): render priority, lower-values drawn first
-
TextGraphics
public TextGraphics(String text, float fontSize, Color fillColor, Color outlineColor, float thickness, boolean bold, boolean italics, Vector anchor) Creates a new text graphics.- Parameters:
text- (String): content, not nullfontSize- (float): sizefillColor- (Color): fill color, may be nulloutlineColor- (Color): outline color, may be nullthickness- (float): outline thicknessbold- (boolean): whether to use bold fontitalics- (boolean): whether to use italics fontanchor- (Vector): text anchor
-
TextGraphics
Creates a new text graphics.- Parameters:
text- (String): content, not nullfontSize- (float): sizefillColor- (Color): fill color, may be null
-
-
Method Details
-
setText
Sets text content.- Parameters:
text- (String): content, not null
-
getText
- Returns:
- (String): text content, not null
-
setFontSize
public void setFontSize(float fontSize) Sets font size.- Parameters:
fontSize- (float): size
-
getFontSize
public float getFontSize()- Returns:
- (float): font size
-
setFillColor
Sets fill color.- Parameters:
fillColor- (Color): color, may be null
-
getFillColor
- Returns:
- (Color): fill color, may be null
-
setOutlineColor
Sets outline color.- Parameters:
outlineColor- (Color): color, may be null
-
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
-
setFontName
Set the font name- Parameters:
fontName- (String): the font name
-
getFontName
- Returns:
- (String): the font name
-
setBold
public void setBold(boolean bold) Sets bold font.- Parameters:
bold- (boolean): whether to use bold font
-
isBold
public boolean isBold()- Returns:
- (boolean): whether to use bold font
-
setItalics
public void setItalics(boolean italics) Sets italics font.- Parameters:
italics- (boolean): whether to use italics font
-
isItalics
public boolean isItalics()- Returns:
- (boolean): whether to use italics font
-
setAnchor
Sets text anchor, i.e. how to orient it.- Parameters:
anchor- (Vector): text anchor
-
getAnchor
- Returns:
- (Vector): text anchor
-
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.
-