SFML 2.6.2

- Main Page
- Related Pages
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Shape.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
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#ifndef SFML_SHAPE_HPP
26#define SFML_SHAPE_HPP
27
29// Headers
31#include <SFML/Graphics/Export.hpp>
32#include <SFML/Graphics/Drawable.hpp>
33#include <SFML/Graphics/Transformable.hpp>
34#include <SFML/Graphics/VertexArray.hpp>
35#include <SFML/System/Vector2.hpp>
36
37
38 namespace sf
39{
44 class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
45{
46 public:
47
52 virtual ~Shape();
53
74 void setTexture(const Texture* texture, bool resetRect = false);
75
88 void setTextureRect(const IntRect& rect);
89
105 void setFillColor(const Color& color);
106
117 void setOutlineColor(const Color& color);
118
132 void setOutlineThickness(float thickness);
133
146 const Texture* getTexture() const;
147
156 const IntRect& getTextureRect() const;
157
166 const Color& getFillColor() const;
167
176 const Color& getOutlineColor() const;
177
186 float getOutlineThickness() const;
187
196 virtual std::size_t getPointCount() const = 0;
197
213 virtual Vector2f getPoint(std::size_t index) const = 0;
214
227 FloatRect getLocalBounds() const;
228
248 FloatRect getGlobalBounds() const;
249
250 protected:
251
256 Shape();
257
266 void update();
267
268 private:
269
277 virtual void draw(RenderTarget& target, RenderStates states) const;
278
283 void updateFillColors();
284
289 void updateTexCoords();
290
295 void updateOutline();
296
301 void updateOutlineColors();
302
303 private:
304
306 // Member data
308 const Texture* m_texture;
309 IntRect m_textureRect;
310 Color m_fillColor;
311 Color m_outlineColor;
312 float m_outlineThickness;
313 VertexArray m_vertices;
314 VertexArray m_outlineVertices;
315 FloatRect m_insideBounds;
316 FloatRect m_bounds;
317};
318
319} // namespace sf
320
321
322#endif // SFML_SHAPE_HPP
323
324
Drawable.hpp
Export.hpp
SFML_GRAPHICS_API
#define SFML_GRAPHICS_API
Definition Graphics/Export.hpp:43
Transformable.hpp
Vector2.hpp
VertexArray.hpp
sf::Color
Utility class for manipulating RGBA colors.
Definition Color.hpp:41
sf::Drawable
Abstract base class for objects that can be drawn to a render target.
Definition Drawable.hpp:45
sf::Rect< int >
sf::RenderStates
Define the states used for drawing to a RenderTarget.
Definition RenderStates.hpp:46
sf::RenderTarget
Base class for all render targets (window, texture, ...)
Definition RenderTarget.hpp:53
sf::Shape
Base class for textured shapes with outline.
Definition Shape.hpp:45
sf::Shape::getOutlineThickness
float getOutlineThickness() const
Get the outline thickness of the shape.
sf::Shape::setTextureRect
void setTextureRect(const IntRect &rect)
Set the sub-rectangle of the texture that the shape will display.
sf::Shape::~Shape
virtual ~Shape()
Virtual destructor.
sf::Shape::setFillColor
void setFillColor(const Color &color)
Set the fill color of the shape.
sf::Shape::getPoint
virtual Vector2f getPoint(std::size_t index) const =0
Get a point of the shape.
sf::Shape::Shape
Shape()
Default constructor.
sf::Shape::getOutlineColor
const Color & getOutlineColor() const
Get the outline color of the shape.
sf::Shape::setOutlineColor
void setOutlineColor(const Color &color)
Set the outline color of the shape.
sf::Shape::setOutlineThickness
void setOutlineThickness(float thickness)
Set the thickness of the shape's outline.
sf::Shape::getFillColor
const Color & getFillColor() const
Get the fill color of the shape.
sf::Shape::getGlobalBounds
FloatRect getGlobalBounds() const
Get the global (non-minimal) bounding rectangle of the entity.
sf::Shape::getTextureRect
const IntRect & getTextureRect() const
Get the sub-rectangle of the texture displayed by the shape.
sf::Shape::update
void update()
Recompute the internal geometry of the shape.
sf::Shape::getLocalBounds
FloatRect getLocalBounds() const
Get the local bounding rectangle of the entity.
sf::Shape::getTexture
const Texture * getTexture() const
Get the source texture of the shape.
sf::Shape::setTexture
void setTexture(const Texture *texture, bool resetRect=false)
Change the source texture of the shape.
sf::Shape::getPointCount
virtual std::size_t getPointCount() const =0
Get the total number of points of the shape.
sf::Texture
Image living on the graphics card that can be used for drawing.
Definition Texture.hpp:49
sf::Transformable
Decomposed transform defined by a position, a rotation and a scale.
Definition Transformable.hpp:42
sf::Vector2< float >
sf::VertexArray
Define a set of one or more 2D primitives.
Definition VertexArray.hpp:46
sf
Definition AlResource.hpp:35