TGUI
1.1
|
Public Types | |
enum class | ScalingType { Normal , Horizontal , Vertical , NineSlice } |
The way the image should be scaled. More... | |
Public Member Functions | |
Sprite ()=default | |
Default constructor. | |
Sprite (const Texture &texture) | |
Constructor that immediately sets the texture. | |
Sprite (const Sprite &) | |
Copy constructor. | |
Sprite (Sprite &&) noexcept | |
Move constructor. | |
~Sprite () | |
Destructor. | |
Sprite & | operator= (const Sprite &) |
Overload of copy assignment operator. | |
Sprite & | operator= (Sprite &&) noexcept |
Move assignment. | |
void | setTexture (const Texture &texture) |
Changes the texture. | |
TGUI_NODISCARD const Texture & | getTexture () const |
Returns the texture used by this sprite. | |
TGUI_NODISCARD bool | isSet () const |
Returns whether a texture was set. | |
void | setSize (const Vector2f &size) |
Changes the size that the image will have when drawing. | |
TGUI_NODISCARD Vector2f | getSize () const |
Returns the size that the image has when drawing. | |
void | setOpacity (float opacity) |
Changes the opacity of the texture. | |
TGUI_NODISCARD float | getOpacity () const |
Returns the opacity of the texture. | |
void | setVisibleRect (const FloatRect &visibleRect) |
Changes the part of the sprite that should be drawn. | |
TGUI_NODISCARD FloatRect | getVisibleRect () const |
Returns the part of the sprite that is drawn. | |
void | setPosition (Vector2f position) |
Sets the position of the sprite. | |
TGUI_NODISCARD Vector2f | getPosition () const |
Gets the position of the sprite. | |
void | setRotation (float angle) |
Sets rotation of the sprite. | |
TGUI_NODISCARD float | getRotation () const |
Gets rotation of the sprite. | |
TGUI_NODISCARD bool | isTransparentPixel (Vector2f pos) const |
Checks if a certain pixel is transparent. | |
TGUI_NODISCARD ScalingType | getScalingType () const |
Returns the way in which the image is being scaled. | |
TGUI_NODISCARD const std::shared_ptr< BackendTexture > & | getSvgTexture () const |
TGUI_NODISCARD const std::vector< Vertex > & | getVertices () const |
TGUI_NODISCARD const std::vector< unsigned int > & | getIndices () const |
void | updateVertices () |
|
strong |
The way the image should be scaled.
tgui::Sprite::Sprite | ( | const Texture & | texture | ) |
Constructor that immediately sets the texture.
texture | Texture to use in the sprite |
TGUI_NODISCARD float tgui::Sprite::getOpacity | ( | ) | const |
Returns the opacity of the texture.
TGUI_NODISCARD Vector2f tgui::Sprite::getPosition | ( | ) | const |
Gets the position of the sprite.
TGUI_NODISCARD float tgui::Sprite::getRotation | ( | ) | const |
Gets rotation of the sprite.
TGUI_NODISCARD ScalingType tgui::Sprite::getScalingType | ( | ) | const |
Returns the way in which the image is being scaled.
TGUI_NODISCARD Vector2f tgui::Sprite::getSize | ( | ) | const |
Returns the size that the image has when drawing.
TGUI_NODISCARD const Texture & tgui::Sprite::getTexture | ( | ) | const |
Returns the texture used by this sprite.
TGUI_NODISCARD FloatRect tgui::Sprite::getVisibleRect | ( | ) | const |
Returns the part of the sprite that is drawn.
TGUI_NODISCARD bool tgui::Sprite::isSet | ( | ) | const |
Returns whether a texture was set.
TGUI_NODISCARD bool tgui::Sprite::isTransparentPixel | ( | Vector2f | pos | ) | const |
Checks if a certain pixel is transparent.
pos | Coordinate of the pixel |
void tgui::Sprite::setOpacity | ( | float | opacity | ) |
Changes the opacity of the texture.
opacity | The opacity of the texture. 0 means completely transparent, while 1 (default) means fully opaque |
The alpha component of the color specified with setColor is multiplied with this factor.
void tgui::Sprite::setPosition | ( | Vector2f | position | ) |
Sets the position of the sprite.
position | New sprite position |
void tgui::Sprite::setRotation | ( | float | angle | ) |
Sets rotation of the sprite.
angle | Degrees to rotate counterclockwise |
Rotation can currently only be a multiple of 90 degrees.
void tgui::Sprite::setSize | ( | const Vector2f & | size | ) |
Changes the size that the image will have when drawing.
size | Size of the sprite |
void tgui::Sprite::setTexture | ( | const Texture & | texture | ) |
Changes the texture.
texture | New texture |
void tgui::Sprite::setVisibleRect | ( | const FloatRect & | visibleRect | ) |
Changes the part of the sprite that should be drawn.
visibleRect | Visible part of the sprite |
Set this to (0, 0, 0, 0) to show the entire sprite