![]() |
Gamedev Framework (gf)
0.10.0
A C++14 framework for 2D games
|
All the core generic classes and functions. More...
Classes | |
class | gf::Array2D< T, I > |
A two-dimensional array. More... | |
class | gf::ArrayRef< T > |
A constant reference to an array and its size. More... | |
struct | gf::Box< T, N > |
A multi-dimensional box. More... | |
class | gf::BufferRef< T > |
A reference to a modifiable buffer and its size. More... | |
struct | gf::Circ< T > |
Utility class for manipulating circles. More... | |
class | gf::Clock |
Utility class that measures the elapsed time. More... | |
class | gf::Ease |
Predefined easing functions. More... | |
class | gf::Flags< E > |
Bitfield relying on an enumeration. More... | |
class | gf::Bresenham |
State for the Bresenham's line algorithm. More... | |
class | gf::Heightmap |
A heightmap. More... | |
struct | gf::Library::Version |
Information about version. More... | |
class | gf::Library |
A class to represent the library. More... | |
class | gf::Log |
Logging functions. More... | |
struct | gf::Matrix< T, ROWS, COLS > |
General purpose math matrix. More... | |
struct | gf::Matrix< T, 2, 2 > |
A 2x2 matrix. More... | |
struct | gf::Matrix< T, 3, 3 > |
A 3x3 matrix. More... | |
struct | gf::Matrix< T, 4, 4 > |
A 4x4 matrix. More... | |
class | gf::Noise2D |
2D A noise function More... | |
class | gf::Noise3D |
3D A noise function More... | |
class | gf::ValueNoise2D |
Value 2D noise. More... | |
class | gf::GradientNoise2D |
Gradient 2D noise. More... | |
class | gf::GradientNoise3D |
Gradient 3D noise. More... | |
class | gf::BetterGradientNoise2D |
Better gradient 2D noise. More... | |
class | gf::FractalNoise2D |
Fractal 2D noise. More... | |
class | gf::FractalNoise3D |
Fractal 3D noise. More... | |
class | gf::PerlinNoise2D |
Perlin 2D noise. More... | |
class | gf::PerlinNoise3D |
Perlin 3D noise. More... | |
class | gf::SimplexNoise2D |
Simplex 2D noise. More... | |
class | gf::OpenSimplexNoise2D |
OpenSimplex 2D noise. More... | |
class | gf::OpenSimplexNoise3D |
OpenSimplex3D noise. More... | |
class | gf::WaveletNoise3D |
Wavelet 3D noise. More... | |
class | gf::WorleyNoise2D |
Worley 2D noise. More... | |
class | gf::Multifractal2D |
Multi Fractal 2D noise. More... | |
class | gf::HeteroTerrain2D |
Hetero Terrain 2D noise. More... | |
class | gf::HybridMultifractal2D |
Hybrid Multifractal 2D noise. More... | |
class | gf::RidgedMultifractal2D |
Ridged Multifractal 2D noise. More... | |
class | gf::Noise3DTo2DAdapter |
An adapter that make a 2D noise from a 3D noise. More... | |
struct | gf::Paths |
Special paths. More... | |
class | gf::Polygon |
A convex polygon. More... | |
class | gf::Polyline |
A polyline. More... | |
class | gf::Queue< T > |
A simple concurrent queue. More... | |
class | gf::Random |
A random engine. More... | |
struct | gf::Range< T >::Iterator |
A range iterator. More... | |
struct | gf::Range< T > |
A half-open range of values. More... | |
struct | gf::PositionRange< T >::Iterator |
An iterator for a 2D range. More... | |
struct | gf::PositionRange< T > |
A 2D range. More... | |
struct | gf::Rect< T > |
Utility class for manipulating 2D axis aligned rectangles. More... | |
class | gf::Singleton< T > |
A singleton that wraps a pointer provided by a storage. More... | |
class | gf::SingletonStorage< T > |
A storage for a singleton. More... | |
struct | gf::RStarTree< T, U, N, MaxSize, MinSize >::Node::SplitResult |
class | gf::QuadTree< T, U, Size > |
An implementation of quadtree. More... | |
class | gf::RStarTree< T, U, N, MaxSize, MinSize > |
An implemntation of a R* tree. More... | |
class | gf::InputStream |
Abstract class for custom file input streams. More... | |
class | gf::OutputStream |
Abstract class for custom file output streams. More... | |
class | gf::FileInputStream |
File based input stream. More... | |
class | gf::MemoryInputStream |
Memory based input stream. More... | |
class | gf::CompressedInputStream |
Compressed input stream. More... | |
class | gf::FileOutputStream |
File based output stream. More... | |
class | gf::MemoryOutputStream |
Memory based output stream. More... | |
class | gf::CompressedOutputStream |
Compressed output stream. More... | |
class | gf::StringRef |
A constant reference to a string and its size. More... | |
class | gf::SystemInfo |
A class for system info. More... | |
class | gf::Time |
Represents a time value. More... | |
class | gf::EdgeRef< T > |
A reference to an edge (two points) More... | |
class | gf::TriangleRef< T > |
A reference to a triangle (three points) More... | |
struct | gf::NoneType |
Semantic type to represent "none". More... | |
struct | gf::AllType |
Semantic type to represent "all". More... | |
struct | gf::ZeroType |
Semantic type to represent "zero". More... | |
struct | gf::Vector< T, N > |
General purpose math vector. More... | |
struct | gf::Vector< T, 2 > |
A 2D vector. More... | |
struct | gf::Vector< T, 3 > |
A 3D vector. More... | |
struct | gf::Vector< T, 4 > |
A 4D vector. More... | |
Typedefs | |
using | gf::CircF = Circ< float > |
A float circle. More... | |
using | gf::CircI = Circ< int > |
A int circle. More... | |
using | gf::CircU = Circ< unsigned > |
A unsigned circle. More... | |
using | gf::CircZ = Circ< std::size_t > |
A std::size_t circle. More... | |
using | gf::Easing = float(*)(float) |
An easing function. More... | |
using | gf::Id = uint64_t |
An identifier. More... | |
template<typename T > | |
using | gf::Step = T(*)(T) |
A step is a function with special features. More... | |
using | gf::Matrix2f = Matrix< float, 2, 2 > |
A float square matrix of size 2. More... | |
using | gf::Matrix3f = Matrix< float, 3, 3 > |
A float square matrix of size 3. More... | |
using | gf::Matrix4f = Matrix< float, 4, 4 > |
A float square matrix of size 4. More... | |
using | gf::Path = boost::filesystem::path |
A path in the filesystem. More... | |
using | gf::RangeF = Range< float > |
A float range. More... | |
using | gf::RangeI = Range< int > |
A int range. More... | |
using | gf::RangeU = Range< unsigned > |
A unsigned range. More... | |
using | gf::RangeZ = Range< std::size_t > |
A std::size_t range. More... | |
using | gf::RectF = Rect< float > |
A float rectangle. More... | |
using | gf::RectI = Rect< int > |
A int rectangle. More... | |
using | gf::RectU = Rect< unsigned > |
A unsigned rectangle. More... | |
using | gf::RectZ = Rect< std::size_t > |
A std::size_t rectangle. More... | |
template<typename T > | |
using | gf::SpatialQueryCallback = std::function< void(const T &)> |
A callback for spatial query. More... | |
using | gf::Vector2f = Vector< float, 2 > |
A float vector with 2 components. More... | |
using | gf::Vector3f = Vector< float, 3 > |
A float vector with 3 components. More... | |
using | gf::Vector4f = Vector< float, 4 > |
A float vector with 4 components. More... | |
using | gf::Vector2d = Vector< double, 2 > |
A double vector with 2 components. More... | |
using | gf::Vector3d = Vector< double, 3 > |
A double vector with 3 components. More... | |
using | gf::Vector4d = Vector< double, 4 > |
A double vector with 4 components. More... | |
using | gf::Vector2i = Vector< int, 2 > |
A int vector with 2 components. More... | |
using | gf::Vector3i = Vector< int, 3 > |
A int vector with 3 components. More... | |
using | gf::Vector4i = Vector< int, 4 > |
A int vector with 4 components. More... | |
using | gf::Vector2u = Vector< unsigned, 2 > |
A unsigned vector with 2 components. More... | |
using | gf::Vector3u = Vector< unsigned, 3 > |
A unsigned vector with 3 components. More... | |
using | gf::Vector4u = Vector< unsigned, 4 > |
A unsigned vector with 4 components. More... | |
using | gf::Vector2z = Vector< std::size_t, 2 > |
A std::size_t vector with 2 components. More... | |
using | gf::Vector3z = Vector< std::size_t, 3 > |
A std::size_t vector with 3 components. More... | |
using | gf::Vector4z = Vector< std::size_t, 4 > |
A std::size_t vector with 4 components. More... | |
using | gf::Vector2b = Vector< bool, 2 > |
A bool vector with 2 components. More... | |
using | gf::Vector3b = Vector< bool, 3 > |
A bool vector with 3 components. More... | |
using | gf::Vector4b = Vector< bool, 4 > |
A bool vector with 4 components. More... | |
using | gf::Color3f = Vector< float, 3 > |
A float color vector with 3 components. More... | |
using | gf::Color4f = Vector< float, 4 > |
A float color vector with 4 components. More... | |
using | gf::Color3u = Vector< uint8_t, 3 > |
A uint8_t color vector with 3 components. More... | |
using | gf::Color4u = Vector< uint8_t, 4 > |
A uint8_t color vector with 4 components. More... | |
template<typename T , std::size_t N> | |
using | gf::Distance = T(*)(Vector< T, N >, Vector< T, N >) |
A distance function. More... | |
template<typename T > | |
using | gf::Distance2 = Distance< T, 2 > |
A distance function for 2D vectors. More... | |
template<typename T > | |
using | gf::Distance3 = Distance< T, 3 > |
A distance function for 3D vectors. More... | |
Functions | |
Vector2f | gf::unit (Direction direction) |
Get a unit vector from a direction. More... | |
Vector2i | gf::displacement (Direction direction) |
Get a vector from a direction. More... | |
float | gf::angle (Direction direction) |
Get an angle from a direction. More... | |
Direction | gf::opposite (Direction direction) |
Get the opposite direction. More... | |
Direction | gf::orthogonalCW (Direction direction) |
Get the orthogonal direction clockwise. More... | |
Direction | gf::orthogonalCCW (Direction direction) |
Get the orthogonal direction counter-clockwise. More... | |
Direction | gf::nextCW (Direction direction) |
Get the next direction clockwise. More... | |
Direction | gf::nextCCW (Direction direction) |
Get the next direction counter-clockwise. More... | |
std::vector< Vector2i > | gf::generateLine (Vector2i p0, Vector2i p1) |
Generate a line between two positions. More... | |
std::vector< Vector2f > | gf::midpointDisplacement1D (Vector2f p0, Vector2f p1, Random &random, unsigned iterations, Vector2f direction, float initialFactor=1.0f, float reductionFactor=0.5f) |
1D midpoint displacement More... | |
std::vector< Vector2f > | gf::midpointDisplacement1D (Vector2f p0, Vector2f p1, Random &random, unsigned iterations, float initialFactor=1.0f, float reductionFactor=0.5f) |
1D midpoint displacement More... | |
Heightmap | gf::midpointDisplacement2D (Vector2i size, Random &random, ArrayRef< double > initialValues=nullptr) |
2D midpoint displacement More... | |
Heightmap | gf::diamondSquare2D (Vector2i size, Random &random, ArrayRef< double > initialValues=nullptr) |
2D diamond square More... | |
Polygon | gf::convexHull (ArrayRef< Vector2f > points) |
Compute the convex hull of a set of points. More... | |
std::vector< Vector2f > | gf::simplifyPoints (ArrayRef< Vector2f > points, float distance=Epsilon) |
Simplify a sequence of points. More... | |
constexpr Id | gf::hash (const char *str, std::size_t sz) |
Get an identifier from a string. More... | |
constexpr Id | gf::hash (StringRef str) |
Get an idenfitier from a string. More... | |
template<typename T > | |
bool | gf::almostEquals (T a, T b, T epsilon=std::numeric_limits< T >::epsilon()) |
Compare two floats. More... | |
constexpr float | gf::degreesToRadians (float degrees) |
Convert degrees to radians. More... | |
constexpr float | gf::radiansToDegrees (float radians) |
Convert radians to degrees. More... | |
template<typename T > | |
constexpr T | gf::linearStep (T t) |
Linear step. More... | |
template<typename T > | |
constexpr T | gf::cubicStep (T t) |
Cubic step (smoothstep) More... | |
template<typename T > | |
constexpr T | gf::quinticStep (T t) |
Quintic step (smootherstep) More... | |
template<typename T > | |
T | gf::cosineStep (T t) |
Cosine step. More... | |
template<typename T , typename U > | |
constexpr T | gf::lerp (T lhs, T rhs, U t) |
Linear interpolation function. More... | |
template<typename T > | |
constexpr T | gf::clamp (T val, T lo, T hi) |
Clamping function. More... | |
template<typename T > | |
constexpr T | gf::square (T val) |
Square function. More... | |
template<typename T > | |
constexpr int | gf::sign (T val) |
Sign function. More... | |
template<typename T > | |
constexpr T | gf::absdiff (T lhs, T rhs) |
Absolute difference of two values. More... | |
float | gf::angularFactor (AngularMove move) |
Get the angular factor from the angular move. More... | |
float | gf::linearFactor (LinearMove move) |
Get the linear factor from the linear move. More... | |
Vector2f | gf::unit (Orientation orientation) |
Get a unit vector from an orientation. More... | |
Vector2i | gf::displacement (Orientation orientation) |
Get a vector from an orientation. More... | |
float | gf::angle (Orientation orientation) |
Get an angle from a orientation. More... | |
Orientation | gf::opposite (Orientation orientation) |
Get the opposite orientation. More... | |
Orientation | gf::orthogonalCW (Orientation orientation) |
Get the orthogonal orientation clockwise. More... | |
Orientation | gf::orthogonalCCW (Orientation orientation) |
Get the orthogonal orientation counter-clockwise. More... | |
Orientation | gf::nextCW (Orientation orientation) |
Get the next orientation clockwise. More... | |
Orientation | gf::nextCCW (Orientation orientation) |
Get the next orientation counter-clockwise. More... | |
void | gf::sleep (Time duration) |
Make the current thread sleep for a given duration. More... | |
std::string | gf::niceNum (float num, float precision) |
Create a string representation of a floating point number. More... | |
std::u32string | gf::computeUnicodeString (StringRef str) |
Compute a UTF-32 string from a UTF-8 string. More... | |
std::string | gf::formatString (const char *fmt,...) |
Format a string like printf. More... | |
std::string | gf::formatString (const char *fmt, va_list ap) |
Format a string like vprintf. More... | |
std::vector< std::u32string > | gf::splitInParagraphs (const std::u32string &str) |
constexpr Vector2f | gf::transform (const Matrix3f &mat, Vector2f point) |
Apply an affine transformation to a 2D point. More... | |
RectF | gf::transform (const Matrix3f &mat, const RectF &rect) |
Apply an affine transformaton to a rectangle. More... | |
constexpr Matrix3f | gf::identityTransform () |
Identity transform. More... | |
Matrix3f | gf::translation (Vector2f offset) |
Get a translation matrix. More... | |
void | gf::translate (Matrix3f &mat, Vector2f offset) |
Combine the current transform with a translation. More... | |
Matrix3f | gf::rotation (float angle) |
Get a rotation matrix. More... | |
Matrix3f | gf::rotation (float angle, Vector2f center) |
Get a rotation matrix. More... | |
void | gf::rotate (Matrix3f &mat, float angle) |
Combine the current transform with a rotation. More... | |
void | gf::rotate (Matrix3f &mat, float angle, Vector2f center) |
Combine the current transform with a rotation. More... | |
Matrix3f | gf::scaling (Vector2f factor) |
Get a scaling matrix. More... | |
Matrix3f | gf::scaling (Vector2f factor, Vector2f center) |
Get a scaling matrix. More... | |
void | gf::scale (Matrix3f &mat, Vector2f factor) |
Combine the current transform with a scaling. More... | |
void | gf::scale (Matrix3f &mat, Vector2f factor, Vector2f center) |
Combine the current transform with a scaling. More... | |
std::vector< TriangleRef< const Vector2f > > | gf::triangulation (ArrayRef< Vector2f > points) |
Compute a Delaunay triangulation of a set of points. More... | |
template<typename... Args> | |
void | gf::unused (Args &&...) |
A simple way to avoid warnings about unused variables. More... | |
Variables | |
constexpr Id | gf::InvalidId = 0 |
The invalid id (which is 0) More... | |
constexpr float | gf::Pi = 3.14159265358979323846f |
The \( \pi \) constant. More... | |
constexpr float | gf::Pi2 = Pi / 2 |
The \( \frac{\pi}{2} \) constant. More... | |
constexpr float | gf::Pi4 = Pi / 4 |
The \( \frac{\pi}{4} \) constant. More... | |
constexpr float | gf::Sqrt2 = 1.41421356237309504880f |
The \( \sqrt{2} \) constant. More... | |
constexpr float | gf::InvSqrt2 = 1 / Sqrt2 |
The \( \frac{1}{\sqrt{2}} \) constant. More... | |
constexpr float | gf::Sqrt3 = 1.7320508075688772935f |
The \( \sqrt{3} \) constant. More... | |
constexpr float | gf::Epsilon = std::numeric_limits<float>::epsilon() |
Machine epsilon. More... | |
constexpr NoneType | gf::None = { } |
Constant to represent "none". More... | |
constexpr AllType | gf::All = { } |
Constant to represent "all". More... | |
constexpr ZeroType | gf::Zero = { } |
Constant to represent "zero". More... | |
All the core generic classes and functions.
using gf::Color3f = typedef Vector<float, 3> |
A float color vector with 3 components.
using gf::Color3u = typedef Vector<uint8_t, 3> |
A uint8_t color vector with 3 components.
using gf::Color4f = typedef Vector<float, 4> |
A float color vector with 4 components.
using gf::Color4u = typedef Vector<uint8_t, 4> |
A uint8_t color vector with 4 components.
using gf::Distance = typedef T (*)(Vector<T, N>, Vector<T, N>) |
A distance function.
A distance function is a function that gives the distance between two vectors.
using gf::Distance2 = typedef Distance<T, 2> |
A distance function for 2D vectors.
using gf::Distance3 = typedef Distance<T, 3> |
A distance function for 3D vectors.
using gf::Easing = typedef float (*)(float) |
using gf::Id = typedef uint64_t |
An identifier.
using gf::Matrix2f = typedef Matrix<float, 2, 2> |
A float square matrix of size 2.
using gf::Matrix3f = typedef Matrix<float, 3, 3> |
A float square matrix of size 3.
using gf::Matrix4f = typedef Matrix<float, 4, 4> |
A float square matrix of size 4.
using gf::Path = typedef boost::filesystem::path |
A path in the filesystem.
gf::Path is a simple typedef for boost::filesystem::path
. Boost.Filesystem will eventually be part of the C++17 standard. So, in the future, gf::Path will be a typedef for std::path
.
using gf::RangeF = typedef Range<float> |
A float range.
using gf::RangeI = typedef Range<int> |
A int range.
using gf::RangeU = typedef Range<unsigned> |
A unsigned range.
using gf::RangeZ = typedef Range<std::size_t> |
A std::size_t
range.
using gf::SpatialQueryCallback = typedef std::function<void(const T&)> |
A callback for spatial query.
using gf::Step = typedef T (*)(T) |
A step is a function with special features.
A step \( f \) is a (mathematical) function which has the following properties:
It can be used to smooth a linear interpolation.
using gf::Vector2b = typedef Vector<bool, 2> |
A bool vector with 2 components.
using gf::Vector2d = typedef Vector<double, 2> |
A double vector with 2 components.
using gf::Vector2f = typedef Vector<float, 2> |
A float vector with 2 components.
using gf::Vector2i = typedef Vector<int, 2> |
A int vector with 2 components.
using gf::Vector2u = typedef Vector<unsigned, 2> |
A unsigned vector with 2 components.
using gf::Vector2z = typedef Vector<std::size_t, 2> |
A std::size_t vector with 2 components.
using gf::Vector3b = typedef Vector<bool, 3> |
A bool vector with 3 components.
using gf::Vector3d = typedef Vector<double, 3> |
A double vector with 3 components.
using gf::Vector3f = typedef Vector<float, 3> |
A float vector with 3 components.
using gf::Vector3i = typedef Vector<int, 3> |
A int vector with 3 components.
using gf::Vector3u = typedef Vector<unsigned, 3> |
A unsigned vector with 3 components.
using gf::Vector3z = typedef Vector<std::size_t, 3> |
A std::size_t vector with 3 components.
using gf::Vector4b = typedef Vector<bool, 4> |
A bool vector with 4 components.
using gf::Vector4d = typedef Vector<double, 4> |
A double vector with 4 components.
using gf::Vector4f = typedef Vector<float, 4> |
A float vector with 4 components.
using gf::Vector4i = typedef Vector<int, 4> |
A int vector with 4 components.
using gf::Vector4u = typedef Vector<unsigned, 4> |
A unsigned vector with 4 components.
using gf::Vector4z = typedef Vector<std::size_t, 4> |
A std::size_t vector with 4 components.
|
strong |
An angular move.
An angular move represents a rotation move to the right or to the left.
Enumerator | |
---|---|
None | No angular move. |
Left | Move to the left (i.e. counter-clockwise) |
Right | Move to the right (i.e. clockwise) |
|
strong |
Main four directions.
gf::Direction represents one of the four main directions. A special value is added to represent the center, it indicates no direction.
Enumerator | |
---|---|
Center | The center, indicates no direction. |
Up | The up direction. |
Right | The right direction. |
Down | The down direction. |
Left | The left direction. |
|
strong |
A linear move.
A linear move represents a translation move forward or backward.
Enumerator | |
---|---|
None | No linear move. |
Forward | Move forward. |
Backward | Move backward. |
|
strong |
Cardinal and ordinal orientation.
gf::Orientation represents one the four cardinal orientations and the four ordinal (or intercardinal) orientations. A special value is added to represent the center, it indicates no orientation.
|
strong |
|
strong |
constexpr T gf::absdiff | ( | T | lhs, |
T | rhs | ||
) |
Absolute difference of two values.
This function is defined as:
\[ \text{absdiff}(a, b) = | a - b | \]
lhs | The first value |
rhs | The second value |
|
inline |
Compare two floats.
a | The first float |
b | The second float |
epsilon | A small value that controls the equality comparison |
float gf::angle | ( | Direction | direction | ) |
Get an angle from a direction.
Up is at angle 0 and angle grows clockwise.
direction | The direction |
float gf::angle | ( | Orientation | orientation | ) |
Get an angle from a orientation.
North is at angle 0 and angle grows clockwise.
orientation | The orientation |
float gf::angularFactor | ( | AngularMove | move | ) |
Get the angular factor from the angular move.
constexpr T gf::clamp | ( | T | val, |
T | lo, | ||
T | hi | ||
) |
Clamping function.
This function takes a value and returns it if it is in a specified range. If not, the returned value is the nearest value in the range.
val | The value to clamp |
lo | The minimum accepted value |
hi | The maximum accepted value |
std::u32string gf::computeUnicodeString | ( | StringRef | str | ) |
Compute a UTF-32 string from a UTF-8 string.
str | A UTF-8 string |
Compute the convex hull of a set of points.
This function uses the Quickhull algorithm.
Complexity: \( O(n \log n)\) on average, \( O(n^2) \) on worst case
points | The set of points |
|
inline |
constexpr T gf::cubicStep | ( | T | t | ) |
Cubic step (smoothstep)
\[ f(t) = -2 * t^3 + 3 * t^2 \]
Compared to a step, it has the following properties:
This function is also known as smoothstep
constexpr float gf::degreesToRadians | ( | float | degrees | ) |
Convert degrees to radians.
degrees | An angle in degrees |
Heightmap gf::diamondSquare2D | ( | Vector2i | size, |
Random & | random, | ||
ArrayRef< double > | initialValues = nullptr |
||
) |
2D diamond square
The size can be anything. If the size is not a power of two plus one, then a greater heightmap is generated and a submap of the right size is returned (in the middle of the generated map).
The function takes initial values. If there are less than three values, only the first one is used to initialize the four corners. If there are more than four, only the first four are used to initialize the four corners in that order: north-west, north-east, south-east, south-west. If no values are given, the four corners are initialized to \( 0.0 \).
size | The size of the map |
random | A random engine |
initialValues | The initial values of the four corners |
Get a vector from a direction.
The vector has its coordinates at -1, 0 or 1 depending on the direction. It can be used to represent the displacement on a grid in the given direction.
direction | The direction |
Vector2i gf::displacement | ( | Orientation | orientation | ) |
Get a vector from an orientation.
The vector has its coordinates at -1, 0 or 1 depending on the orientation. It can be used to represent the displacement on a grid in the given orientation.
orientation | The orientation |
std::string gf::formatString | ( | const char * | fmt, |
... | |||
) |
Format a string like printf.
fmt | The format string |
std::string gf::formatString | ( | const char * | fmt, |
va_list | ap | ||
) |
Format a string like vprintf.
fmt | The format string |
ap | The arguments of the format string |
Generate a line between two positions.
This function uses Bresenham's line algorithm.
p0 | The first point of the line |
p1 | The last point of the line |
constexpr Id gf::hash | ( | const char * | str, |
std::size_t | sz | ||
) |
Get an identifier from a string.
The hash is a Fowler–Noll–Vo 1a hash. This function is mainly for internal use. You should instead use the user-defined literal _id
.
Example:
str | The string |
sz | The size of the string |
Get an idenfitier from a string.
The hash is a Fowler–Noll–Vo 1a hash. This function can be used for computing an id at runtime. For computing an id from a string at compile time, you should use the the user-defined literal _id
.
str | The string |
constexpr Matrix3f gf::identityTransform | ( | ) |
Identity transform.
constexpr T gf::lerp | ( | T | lhs, |
T | rhs, | ||
U | t | ||
) |
Linear interpolation function.
This functions returns an interpolated value between two values lhs
and rhs
according to a parameter \( t \). When \( t = 0 \) then lhs
is returned, and when \( t = 1 \) then rhs
is returned.
lhs | The first value |
rhs | The second value |
t | The interpolation parameter, generally in the interval \( [0,1] \) |
float gf::linearFactor | ( | LinearMove | move | ) |
Get the linear factor from the linear move.
constexpr T gf::linearStep | ( | T | t | ) |
std::vector<Vector2f> gf::midpointDisplacement1D | ( | Vector2f | p0, |
Vector2f | p1, | ||
Random & | random, | ||
unsigned | iterations, | ||
Vector2f | direction, | ||
float | initialFactor = 1.0f , |
||
float | reductionFactor = 0.5f |
||
) |
1D midpoint displacement
p0 | The first end point |
p1 | The second end point |
random | A random engine |
iterations | The number of iterations |
direction | The direction to make a displacement |
initialFactor | The initial factor to apply to the displacement |
reductionFactor | The factor to apply at each iteration |
std::vector<Vector2f> gf::midpointDisplacement1D | ( | Vector2f | p0, |
Vector2f | p1, | ||
Random & | random, | ||
unsigned | iterations, | ||
float | initialFactor = 1.0f , |
||
float | reductionFactor = 0.5f |
||
) |
1D midpoint displacement
The direction is perpendicular to the segment \( [P_0 P_1] \)
p0 | The first end point |
p1 | The second end point |
random | A random engine |
iterations | The number of iterations |
initialFactor | The initial factor to apply to the displacement |
reductionFactor | The factor to apply at each iteration |
Heightmap gf::midpointDisplacement2D | ( | Vector2i | size, |
Random & | random, | ||
ArrayRef< double > | initialValues = nullptr |
||
) |
2D midpoint displacement
The size can be anything. If the size is not a power of two plus one, then a greater heightmap is generated and a submap of the right size is returned (in the middle of the generated map).
The function takes initial values. If there are less than three values, only the first one is used to initialize the four corners. If there are more than four, only the first four are used to initialize the four corners in that order: north-west, north-east, south-east, south-west. If no values are given, the four corners are initialized to \( 0.0 \).
size | The size of the map |
random | A random engine |
initialValues | The initial values of the four corners |
Get the next direction counter-clockwise.
direction | The direction |
Orientation gf::nextCCW | ( | Orientation | orientation | ) |
Get the next orientation counter-clockwise.
orientation | The orientation |
Get the next direction clockwise.
direction | The direction |
Orientation gf::nextCW | ( | Orientation | orientation | ) |
Get the next orientation clockwise.
orientation | The orientation |
std::string gf::niceNum | ( | float | num, |
float | precision | ||
) |
Create a string representation of a floating point number.
It is based on Python niceNum.
num | The number to display |
precision | The precision to use for display |
Get the opposite direction.
direction | The direction |
Orientation gf::opposite | ( | Orientation | orientation | ) |
Get the opposite orientation.
orientation | The orientation |
Get the orthogonal direction counter-clockwise.
direction | The direction |
Orientation gf::orthogonalCCW | ( | Orientation | orientation | ) |
Get the orthogonal orientation counter-clockwise.
orientation | The orientation |
Get the orthogonal direction clockwise.
direction | The direction |
Orientation gf::orthogonalCW | ( | Orientation | orientation | ) |
Get the orthogonal orientation clockwise.
orientation | The orientation |
constexpr T gf::quinticStep | ( | T | t | ) |
Quintic step (smootherstep)
\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]
Compared to a step, it has the following properties:
This function is also known as smootherstep
constexpr float gf::radiansToDegrees | ( | float | radians | ) |
Convert radians to degrees.
radians | An angle in radians |
void gf::rotate | ( | Matrix3f & | mat, |
float | angle | ||
) |
Combine the current transform with a rotation.
mat | The current transform |
angle | The angle of the rotation (in radians) |
Combine the current transform with a rotation.
mat | The current transform |
angle | The angle of the rotation (in radians) |
center | The center of the rotation |
|
inline |
Get a rotation matrix.
angle | The angle of the rotation (in radians) |
angle
radians Get a rotation matrix.
angle | The angle of the rotation (in radians) |
center | The center of the rotation |
angle
radians of origin center
Combine the current transform with a scaling.
mat | The current transform |
factor | The scaling factor |
Combine the current transform with a scaling.
mat | The current transform |
factor | The scaling factor |
center | The center of the scaling |
Get a scaling matrix.
factor | The scaling factor |
factor
Get a scaling matrix.
factor | The scaling factor |
center | The center of the scaling |
factor
of origin center
constexpr int gf::sign | ( | T | val | ) |
Sign function.
The sign function of \( x \) is:
val | A value |
Simplify a sequence of points.
This function uses the Douglas–Peucker algorithm.
points | The sequence of points |
distance | The maximum authorized distance between the original points and the simplified points |
void gf::sleep | ( | Time | duration | ) |
Make the current thread sleep for a given duration.
gf::sleep is the best way to block a program or one of its threads, as it doesn't consume any CPU power.
duration | The time to sleep |
std::vector<std::u32string> gf::splitInParagraphs | ( | const std::u32string & | str | ) |
constexpr T gf::square | ( | T | val | ) |
Square function.
For a value \( x \), the square value is \( x^2 \).
val | A value |
Apply an affine transformation to a 2D point.
mat | The transformation matrix |
point | The point to transform |
Apply an affine transformaton to a rectangle.
The resulting rectangle is axis-aligned
mat | The transformation matrix |
rect | The rectangle to transform |
Combine the current transform with a translation.
mat | The current transform |
offset | The offset of the translation |
Get a translation matrix.
offset | The offset of the translation |
offset
std::vector<TriangleRef<const Vector2f> > gf::triangulation | ( | ArrayRef< Vector2f > | points | ) |
Compute a Delaunay triangulation of a set of points.
points | The set of points |
Get a unit vector from a direction.
direction | The direction |
Vector2f gf::unit | ( | Orientation | orientation | ) |
Get a unit vector from an orientation.
orientation | The orientation |
|
inline |
A simple way to avoid warnings about unused variables.
constexpr AllType gf::All = { } |
Constant to represent "all".
constexpr float gf::Epsilon = std::numeric_limits<float>::epsilon() |
Machine epsilon.
constexpr Id gf::InvalidId = 0 |
The invalid id (which is 0)
constexpr float gf::InvSqrt2 = 1 / Sqrt2 |
The \( \frac{1}{\sqrt{2}} \) constant.
constexpr NoneType gf::None = { } |
Constant to represent "none".
constexpr float gf::Pi = 3.14159265358979323846f |
The \( \pi \) constant.
constexpr float gf::Pi2 = Pi / 2 |
The \( \frac{\pi}{2} \) constant.
constexpr float gf::Pi4 = Pi / 4 |
The \( \frac{\pi}{4} \) constant.
constexpr float gf::Sqrt2 = 1.41421356237309504880f |
The \( \sqrt{2} \) constant.
constexpr float gf::Sqrt3 = 1.7320508075688772935f |
The \( \sqrt{3} \) constant.
constexpr ZeroType gf::Zero = { } |
Constant to represent "zero".