TGUI  0.8-dev
tgui::Sprite Class Reference
Inheritance diagram for tgui::Sprite:

Public Types

enum  ScalingType { ScalingType::Normal, ScalingType::Horizontal, ScalingType::Vertical, ScalingType::NineSlice }
 The way the image should be scaled. More...
 

Public Member Functions

void setTexture (const Texture &texture)
 Changes the texture. More...
 
const TexturegetTexture () const
 Returns the texture used by this sprite. More...
 
TexturegetTexture ()
 Returns a reference to the texture used by this sprite. More...
 
bool isSet () const
 Returns whether a texture was set. More...
 
void setSize (const sf::Vector2f &size)
 Changes the size that the image will have when drawing. More...
 
sf::Vector2f getSize () const
 Returns the size that the image has when drawing. More...
 
void setColor (const sf::Color &color)
 Sets the global color of the sprite. More...
 
const sf::Color & getColor () const
 Returns the global color of the sprite. More...
 
virtual void setOpacity (float opacity)
 Changes the opacity of the texture. More...
 
float getOpacity () const
 Returns the opacity of the texture. More...
 
void setVisibleRect (const sf::FloatRect &visibleRect)
 Changes the part of the sprite that should be drawn. More...
 
sf::FloatRect getVisibleRect () const
 Returns the part of the sprite that is drawn. More...
 
bool isTransparentPixel (sf::Vector2f pos) const
 Checks if a certain pixel is transparent. More...
 
ScalingType getScalingType () const
 Returns the way in which the image is being scaled. More...
 
void draw (sf::RenderTarget &target, sf::RenderStates states) const
 Draws the sprite.
 

Member Enumeration Documentation

◆ ScalingType

The way the image should be scaled.

Enumerator
Normal 

The image is not split and scaled normally.

Horizontal 

Image is split in Left, Middle and Right parts. Left and Right keep ratio, Middle gets stretched.

Vertical 

Image is split in Top, Middle and Bottom parts. Top and Bottom keep ratio, Middle gets stretched.

NineSlice 

Image is split in 9 parts. Corners keep size, sides are stretched in one direction, middle is stretched in both directions.

Member Function Documentation

◆ getColor()

const sf::Color& tgui::Sprite::getColor ( ) const

Returns the global color of the sprite.

This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity.

By default, the sprite's color is opaque white.

Returns
Current color of the sprite

◆ getOpacity()

float tgui::Sprite::getOpacity ( ) const

Returns the opacity of the texture.

Returns
The opacity of the texture. 0 means completely transparent, while 1 (default) means fully opaque

◆ getScalingType()

ScalingType tgui::Sprite::getScalingType ( ) const

Returns the way in which the image is being scaled.

Returns
Scaling type

◆ getSize()

sf::Vector2f tgui::Sprite::getSize ( ) const

Returns the size that the image has when drawing.

Returns
Size of the sprite

◆ getTexture() [1/2]

const Texture& tgui::Sprite::getTexture ( ) const

Returns the texture used by this sprite.

Returns
Texture of the sprite

◆ getTexture() [2/2]

Texture& tgui::Sprite::getTexture ( )

Returns a reference to the texture used by this sprite.

Returns
Reference to the texture of the sprite

◆ getVisibleRect()

sf::FloatRect tgui::Sprite::getVisibleRect ( ) const

Returns the part of the sprite that is drawn.

Returns
Visible part of the sprite

◆ isSet()

bool tgui::Sprite::isSet ( ) const

Returns whether a texture was set.

Parameters
Hasa valid texture been assigned to this sprite?

◆ isTransparentPixel()

bool tgui::Sprite::isTransparentPixel ( sf::Vector2f  pos) const

Checks if a certain pixel is transparent.

Parameters
posCoordinate of the pixel
Returns
True when the pixel is transparent, false when it is not

◆ setColor()

void tgui::Sprite::setColor ( const sf::Color &  color)

Sets the global color of the sprite.

This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity. Note that the alpha component is multiplied with the opacity set by setOpacity.

By default, the sprite's color is opaque white.

Parameters
colorNew color of the sprite

◆ setOpacity()

virtual void tgui::Sprite::setOpacity ( float  opacity)
virtual

Changes the opacity of the texture.

Parameters
opacityThe 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.

◆ setSize()

void tgui::Sprite::setSize ( const sf::Vector2f &  size)

Changes the size that the image will have when drawing.

Parameters
sizeSize of the sprite

◆ setTexture()

void tgui::Sprite::setTexture ( const Texture texture)

Changes the texture.

Parameters
textureNew texture

◆ setVisibleRect()

void tgui::Sprite::setVisibleRect ( const sf::FloatRect &  visibleRect)

Changes the part of the sprite that should be drawn.

Parameters
visibleRectVisible part of the sprite

Set this to (0, 0, 0, 0) to show the entire sprite


The documentation for this class was generated from the following file: