TGUI
=
=
Download
Tutorials
1.0-dev
0.9
0.8
Documentation
1.0-dev
0.9
0.8
Examples
1.0-dev
0.9
0.8
Community
TGUI
1.0-beta
Loading...
Searching...
No Matches
include
TGUI
Sprite.hpp
1
2
//
3
// TGUI - Texus' Graphical User Interface
4
// Copyright (C) 2012-2022 Bruno Van de Velde (vdv_b@tgui.eu)
5
//
6
// This software is provided 'as-is', without any express or implied warranty.
7
// In no event will the authors be held liable for any damages arising from the use of this software.
8
//
9
// Permission is granted to anyone to use this software for any purpose,
10
// including commercial applications, and to alter it and redistribute it freely,
11
// subject to the following restrictions:
12
//
13
// 1. The origin of this software must not be misrepresented;
14
// you must not claim that you wrote the original software.
15
// If you use this software in a product, an acknowledgment
16
// in the product documentation would be appreciated but is not required.
17
//
18
// 2. Altered source versions must be plainly marked as such,
19
// and must not be misrepresented as being the original software.
20
//
21
// 3. This notice may not be removed or altered from any source distribution.
22
//
24
25
26
#ifndef TGUI_SPRITE_HPP
27
#define TGUI_SPRITE_HPP
28
29
#include <TGUI/Texture.hpp>
30
#include <TGUI/Vector2.hpp>
31
#include <TGUI/Rect.hpp>
32
#include <TGUI/Color.hpp>
33
#include <TGUI/RenderStates.hpp>
34
#include <vector>
35
#include <memory>
36
38
39
namespace
tgui
40
{
42
44
class
TGUI_API
Sprite
45
{
46
public
:
47
52
enum class
ScalingType
53
{
54
Normal,
55
Horizontal,
56
Vertical,
57
NineSlice
58
};
59
60
62
public
:
63
64
68
Sprite
() =
default
;
69
70
76
Sprite
(
const
Texture
& texture);
77
78
82
Sprite
(
const
Sprite
&);
83
87
Sprite
(
Sprite
&&) noexcept;
88
92
Sprite
& operator=(const
Sprite
&);
93
97
Sprite
& operator=(
Sprite
&&) noexcept;
98
99
106
void
setTexture(const
Texture
& texture);
107
108
115
const
Texture
& getTexture() const;
116
117
124
bool
isSet() const;
125
126
133
void
setSize(const
Vector2f
& size);
134
135
142
Vector2f
getSize() const;
143
144
153
void
setOpacity(
float
opacity);
154
155
162
float
getOpacity() const;
163
164
173
void
setVisibleRect(const
FloatRect
& visibleRect);
174
175
182
FloatRect
getVisibleRect() const;
183
184
190
void
setPosition(
Vector2f
position);
191
192
198
Vector2f
getPosition() const;
199
200
208
void
setRotation(
float
angle);
209
210
216
float
getRotation() const;
217
218
227
bool
isTransparentPixel(
Vector2f
pos) const;
228
229
236
ScalingType
getScalingType() const;
237
238
243
const std::shared_ptr<
BackendTexture
>& getSvgTexture()
const
244
{
245
return
m_svgTexture;
246
}
247
248
253
const
std::vector<Vertex>& getVertices()
const
254
{
255
return
m_vertices;
256
}
257
258
263
const
std::vector<unsigned int>& getIndices()
const
264
{
265
return
m_indices;
266
}
267
268
270
private
:
271
273
// Update the location of the vertices
275
void
updateVertices();
276
277
279
private
:
280
281
Vector2f m_size;
282
Texture m_texture;
283
std::shared_ptr<BackendTexture> m_svgTexture;
284
std::vector<Vertex> m_vertices;
285
std::vector<unsigned int> m_indices;
286
287
FloatRect m_visibleRect;
288
289
Color m_vertexColor = Color::White;
290
float
m_opacity = 1;
291
float
m_rotation = 0;
292
Vector2f m_position;
293
294
ScalingType m_scalingType = ScalingType::Normal;
295
};
296
298
}
299
301
302
#endif
// TGUI_SPRITE_HPP
tgui::BackendTexture
Base class for texture implementations that depend on the backend.
Definition:
BackendTexture.hpp:41
tgui::Rect< float >
tgui::Sprite
Definition:
Sprite.hpp:45
tgui::Sprite::ScalingType
ScalingType
The way the image should be scaled.
Definition:
Sprite.hpp:53
tgui::Sprite::Sprite
Sprite()=default
Default constructor.
tgui::Sprite::Sprite
Sprite(Sprite &&) noexcept
Move constructor.
tgui::Sprite::Sprite
Sprite(const Texture &texture)
Constructor that immediately sets the texture.
tgui::Sprite::Sprite
Sprite(const Sprite &)
Copy constructor.
tgui::Texture
Definition:
Texture.hpp:52
tgui::Vector2< float >
tgui
Namespace that contains all TGUI functions and classes.
Definition:
AbsoluteOrRelativeValue.hpp:36
Generated on Sat Dec 10 2022 16:04:59 for TGUI by
1.9.5