![]() |
Gamedev Framework (gf)
0.19.0
A C++17 framework for 2D games
|
A hexagonal grid. More...
#include <gf/Grid.h>
Public Member Functions | |
HexagonGrid (MapCellAxis axis, MapCellIndex index, Vector2i gridSize, float radius, const Color4f &color, float lineWidth=1.0f) | |
Constructor. More... | |
void | setGridSize (Vector2i gridSize) |
Set the grid size. More... | |
Vector2i | getGridSize () const noexcept |
Get the grid size. More... | |
void | setRadius (float radius) |
Set the radius of hexagon. More... | |
float | getRadius () const noexcept |
Get the radius of hexagon. More... | |
Vector2f | getHexagonSize () const noexcept |
Get the hexagon size. More... | |
void | setColor (const Color4f &color) |
Set the color of the grid frame. More... | |
const Color4f & | getColor () const noexcept |
Get the color of the grid frame. More... | |
void | setLineWidth (float lineWidth) noexcept |
Set the width of the grid frame. More... | |
float | getLineWidth () const noexcept |
Get the width of the grid frame. More... | |
RectF | getLocalBounds () const |
Get the local bounding rectangle of the entity. More... | |
void | setAnchor (Anchor anchor) |
Set the anchor origin of the entity. More... | |
VertexBuffer | commitGeometry () const |
Create a buffer with the current geometry. More... | |
virtual void | draw (RenderTarget &target, const RenderStates &states) override |
Draw the object to a render target. More... | |
![]() | |
Transformable () | |
Default constructor. More... | |
void | setOrigin (Vector2f origin) |
Set the local origin of the object. More... | |
Vector2f | getOrigin () const |
Get the local origin of the object. More... | |
void | setPosition (Vector2f position) |
Set the position of the object. More... | |
Vector2f | getPosition () const |
Get the position of the object. More... | |
void | move (Vector2f offset) |
Move the object by a given offset. More... | |
void | setRotation (float angle) |
Set the orientation of the object. More... | |
float | getRotation () const |
Get the orientation of the object. More... | |
void | rotate (float angle) |
Rotate the object. More... | |
void | setScale (Vector2f factors) |
Set the scale factors of the object. More... | |
void | setScale (float factor) |
Set the scale factor of the object. More... | |
Vector2f | getScale () const |
Get the current scale of the object. More... | |
void | scale (Vector2f factors) |
Scale the object. More... | |
void | scale (float factor) |
Scale the object. More... | |
Matrix3f | getTransform () const |
Get the combined transform of the object. More... | |
Matrix3f | getInverseTransform () const |
Get the inverse of the combined transform of the object. More... | |
![]() | |
virtual | ~Drawable () |
Virtual desctructor. More... | |
Additional Inherited Members | |
![]() | |
void | setOriginFromAnchorAndBounds (Anchor anchor, const RectF &bounds) |
Set the origin from an anchor and bounds. More... | |
A hexagonal grid.
gf::HexagonGrid::HexagonGrid | ( | MapCellAxis | axis, |
MapCellIndex | index, | ||
Vector2i | gridSize, | ||
float | radius, | ||
const Color4f & | color, | ||
float | lineWidth = 1.0f |
||
) |
Constructor.
axis | The orientation of hexagon cells. X for pointy and Y for flat |
index | The index of data storage. Odd or Even indicate on which col or row is the offset |
gridSize | The number of hexagonal cell in the grid |
radius | The radius of hexagon |
color | The color of the grid frame |
lineWidth | The width of the grid frame |
VertexBuffer gf::HexagonGrid::commitGeometry | ( | ) | const |
Create a buffer with the current geometry.
The geometry is uploaded in the graphics memory so that it's faster to draw.
|
overridevirtual |
Draw the object to a render target.
This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.
target | Render target to draw to |
states | Current render states |
Implements gf::Drawable.
|
inlinenoexcept |
Get the color of the grid frame.
|
inlinenoexcept |
Get the grid size.
|
inlinenoexcept |
Get the hexagon size.
|
inlinenoexcept |
Get the width of the grid frame.
RectF gf::HexagonGrid::getLocalBounds | ( | ) | const |
Get the local bounding rectangle of the entity.
The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
|
inlinenoexcept |
Get the radius of hexagon.
void gf::HexagonGrid::setAnchor | ( | Anchor | anchor | ) |
Set the anchor origin of the entity.
Compute the origin of the entity based on the local bounds and the specified anchor. Internally, this function calls Transformable::setOrigin()
.
anchor | The anchor of the entity |
void gf::HexagonGrid::setColor | ( | const Color4f & | color | ) |
Set the color of the grid frame.
color | The new color of the grid frame |
void gf::HexagonGrid::setGridSize | ( | Vector2i | gridSize | ) |
Set the grid size.
gridSize | The new grid size |
|
inlinenoexcept |
Set the width of the grid frame.
lineWidth | The new width of the grid frame |
void gf::HexagonGrid::setRadius | ( | float | radius | ) |
Set the radius of hexagon.
radius | The new radius of hexagon |