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
0.9.4
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
37
#if TGUI_HAS_BACKEND_SFML
38
#include <SFML/Graphics/Shader.hpp>
39
#endif
40
42
43
namespace
tgui
44
{
46
48
class
TGUI_API
Sprite
49
{
50
public
:
51
56
enum class
ScalingType
57
{
58
Normal,
59
Horizontal,
60
Vertical,
61
NineSlice
62
};
63
64
66
public
:
67
68
72
Sprite
() =
default
;
73
74
80
Sprite
(
const
Texture
& texture);
81
82
86
Sprite
(
const
Sprite
&);
87
91
Sprite
(
Sprite
&&) noexcept;
92
96
Sprite
& operator=(const
Sprite
&);
97
101
Sprite
& operator=(
Sprite
&&) noexcept;
102
103
110
void
setTexture(const
Texture
& texture);
111
112
119
const
Texture
& getTexture() const;
120
121
128
bool
isSet() const;
129
130
137
void
setSize(const
Vector2f
& size);
138
139
146
Vector2f
getSize() const;
147
148
157
void
setOpacity(
float
opacity);
158
159
166
float
getOpacity() const;
167
168
177
void
setVisibleRect(const
FloatRect
& visibleRect);
178
179
186
FloatRect
getVisibleRect() const;
187
188
194
void
setPosition(
Vector2f
position);
195
196
202
Vector2f
getPosition() const;
203
204
212
void
setRotation(
float
angle);
213
214
220
float
getRotation() const;
221
222
231
bool
isTransparentPixel(
Vector2f
pos) const;
232
233
240
ScalingType
getScalingType() const;
241
242
247
const std::shared_ptr<
BackendTextureBase
>& getSvgTexture()
const
248
{
249
return
m_svgTexture;
250
}
251
252
257
const
std::vector<Vertex>& getVertices()
const
258
{
259
return
m_vertices;
260
}
261
262
267
const
std::vector<int>& getIndices()
const
268
{
269
return
m_indices;
270
}
271
272
274
private
:
275
277
// Update the location of the vertices
279
void
updateVertices();
280
281
283
private
:
284
285
Vector2f m_size;
286
Texture m_texture;
287
std::shared_ptr<BackendTextureBase> m_svgTexture;
288
std::vector<Vertex> m_vertices;
289
std::vector<int> m_indices;
290
291
FloatRect m_visibleRect;
292
293
Color m_vertexColor =
Color::White
;
294
float
m_opacity = 1;
295
float
m_rotation = 0;
296
Vector2f m_position;
297
298
ScalingType m_scalingType = ScalingType::Normal;
299
};
300
302
}
303
305
306
#endif
// TGUI_SPRITE_HPP
tgui::BackendTextureBase
Base class for texture implementations that depend on the backend.
Definition:
BackendTexture.hpp:41
tgui::Color::White
static const Color White
White predefined color.
Definition:
Color.hpp:254
tgui::Rect< float >
tgui::Sprite
Definition:
Sprite.hpp:49
tgui::Sprite::ScalingType
ScalingType
The way the image should be scaled.
Definition:
Sprite.hpp:57
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:49
tgui::Vector2< float >
tgui
Namespace that contains all TGUI functions and classes.
Definition:
AbsoluteOrRelativeValue.hpp:36
Generated on Thu Jun 16 2022 23:04:07 for TGUI by
1.9.3