public abstract class Shape extends SFMLNativeObject implements Drawable
Modifier and Type | Field and Description |
---|---|
protected Vector2f[] |
points |
protected boolean |
pointsNeedUpdate |
Constructor and Description |
---|
Shape()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(RenderTarget target,
RenderStates states)
Draws the object to a render target.
|
Color |
getFillColor()
Gets the shape's current fill color.
|
FloatRect |
getGlobalBounds()
Gets the text's global bounding rectangle in the scene,
taking the text's transformation into account.
|
Transform |
getInverseTransform()
Gets the inverse of the current transformation matrix.
|
FloatRect |
getLocalBounds()
Gets the text's local bounding rectangle,
not taking the text's transformation into account.
|
Vector2f |
getOrigin()
Gets the origin of this object.
|
Color |
getOutlineColor()
Gets the shape's current outline color.
|
float |
getOutlineThickness()
Gets the shape's current outline thickness.
|
Vector2f |
getPoint(int i)
Gets a point of the shape.
|
int |
getPointCount()
Gets the amount of points that defines this shape.
|
Vector2f[] |
getPoints()
Gets all the points of the shape.
|
Vector2f |
getPosition()
Gets the position of this object.
|
float |
getRotation()
Gets the rotation angle of this object.
|
Vector2f |
getScale()
Gets the scaling of this object.
|
ConstTexture |
getTexture()
Gets the shape's current texture.
|
IntRect |
getTextureRect()
Gets the shape's current texture portion.
|
Transform |
getTransform()
Gets the current transformation matrix.
|
void |
move(float x,
float y)
Moves this object.
|
void |
move(Vector2f v)
Moves the object.
|
void |
rotate(float angle)
Rotates this object around its origin.
|
void |
scale(float x,
float y)
Scales the object, using its origin as the scaling center.
|
void |
scale(Vector2f factors)
Scales the object, using its origin as the scaling center.
|
void |
setFillColor(Color color)
Sets the fill color of the shape.
|
void |
setOrigin(float x,
float y)
Sets the rotation, scaling and drawing origin of this object.
|
void |
setOrigin(Vector2f v)
Sets the rotation, scaling and drawing origin of this object.
|
void |
setOutlineColor(Color color)
Sets the outline color of the shape.
|
void |
setOutlineThickness(float thickness)
Sets the thickness of the shape's outline.
|
void |
setPosition(float x,
float y)
Sets the position of this object in the scene so that its origin will be exactly on it.
|
void |
setPosition(Vector2f v)
Sets the position of this object in the scene so that its origin will be exactly on it.
|
void |
setRotation(float angle)
Sets the rotation of this object around its origin.
|
void |
setScale(float x,
float y)
Sets the scaling of this object, using its origin as the scaling center.
|
void |
setScale(Vector2f v)
Sets the scaling of this object, using its origin as the scaling center.
|
void |
setTexture(ConstTexture texture)
Sets the texture of the shape without affecting the texture rectangle.
|
void |
setTexture(ConstTexture texture,
boolean resetRect)
Sets the texture of the shape.
|
void |
setTextureRect(IntRect rect)
Sets the portion of the texture that will be used for drawing.
|
finalize, nativeCreate, nativeDelete, nativeSetExPtr
protected boolean pointsNeedUpdate
protected Vector2f[] points
public void setTexture(ConstTexture texture, boolean resetRect)
null
if no texture is to be used.texture
- the texture of the shape, or null
to indicate that no texture
is to be used.resetRect
- true
to reset the texture rect, false
otherwise.public final void setTexture(ConstTexture texture)
null
if no texture is to be used.texture
- the texture of the shape, or null
to indicate that no texture
is to be used.public void setTextureRect(IntRect rect)
-32
will
result in a sprite that is 32 pixels wide and flipped horizontally.rect
- the texture portion.public void setFillColor(Color color)
color
- the new fill color of the shape, or Color.TRANSPARENT
to indicate
that the shape should not be filled.public void setOutlineColor(Color color)
color
- the new outline color of the shape.public void setOutlineThickness(float thickness)
thickness
- the thickness of the shape's outline, or 0 to indicate that no
outline should be drawn.public ConstTexture getTexture()
public IntRect getTextureRect()
public Color getFillColor()
public Color getOutlineColor()
public float getOutlineThickness()
public int getPointCount()
public Vector2f getPoint(int i)
i
- the index of the point to retrieve.public Vector2f[] getPoints()
public FloatRect getLocalBounds()
Sprite.getGlobalBounds()
public FloatRect getGlobalBounds()
Text.getLocalBounds()
public void setPosition(Vector2f v)
Transformable
setPosition
in interface Transformable
v
- the new position.public void setRotation(float angle)
Transformable
setRotation
in interface Transformable
angle
- the new rotation angle in degrees.public void setScale(Vector2f v)
Transformable
setScale
in interface Transformable
v
- the new scaling factors.public void setOrigin(Vector2f v)
Transformable
setOrigin
in interface Transformable
v
- the new origin.public void draw(RenderTarget target, RenderStates states)
Drawable
public final void setPosition(float x, float y)
Transformable
setPosition
in interface Transformable
x
- the new X coordinate.y
- the new Y coordinate.public final void setScale(float x, float y)
Transformable
setScale
in interface Transformable
x
- the new X scaling factor.y
- the new Y scaling factor.public final void setOrigin(float x, float y)
Transformable
setOrigin
in interface Transformable
x
- the new X coordinate of the origin.y
- the new Y coordinate of the origin.public Vector2f getPosition()
Transformable
getPosition
in interface Transformable
public float getRotation()
Transformable
getRotation
in interface Transformable
public Vector2f getScale()
Transformable
getScale
in interface Transformable
public Vector2f getOrigin()
Transformable
getOrigin
in interface Transformable
public final void move(float x, float y)
Transformable
move
in interface Transformable
x
- the X offset added to the current position.y
- the Y offset added to the current position.public final void move(Vector2f v)
Transformable
move
in interface Transformable
v
- the offset vector added to the current position.public final void rotate(float angle)
Transformable
rotate
in interface Transformable
angle
- the rotation angle in degrees.public final void scale(float x, float y)
Transformable
scale
in interface Transformable
x
- the X scaling factor.y
- the Y scaling factor.public final void scale(Vector2f factors)
Transformable
scale
in interface Transformable
factors
- the scaling factors.public Transform getTransform()
Transformable
getTransform
in interface Transformable
public Transform getInverseTransform()
Transformable
getInverseTransform
in interface Transformable