Gamedev Framework (gf)  0.11.0
A C++14 framework for 2D games
Classes | Typedefs | Enumerations | Functions | Variables
Core classes and functions

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::Dice
 A set of dice that can be rolled. 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::Ref< T >
 A reference wrapper. 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...
 

Enumerations

enum  gf::Direction : int {
  gf::Direction::Center = -1,
  gf::Direction::Up = 0,
  gf::Direction::Right = 1,
  gf::Direction::Down = 2,
  gf::Direction::Left = 3
}
 Main four directions. More...
 
enum  gf::AngularMove {
  gf::AngularMove::None,
  gf::AngularMove::Left,
  gf::AngularMove::Right
}
 An angular move. More...
 
enum  gf::LinearMove {
  gf::LinearMove::None,
  gf::LinearMove::Forward,
  gf::LinearMove::Backward
}
 A linear move. More...
 
enum  gf::Orientation : int {
  gf::Orientation::Center = -1,
  gf::Orientation::North = 0,
  gf::Orientation::NorthEast = 1,
  gf::Orientation::East = 2,
  gf::Orientation::SouthEast = 3,
  gf::Orientation::South = 4,
  gf::Orientation::SouthWest = 5,
  gf::Orientation::West = 6,
  gf::Orientation::NorthWest = 7
}
 Cardinal and ordinal orientation. More...
 
enum  gf::SpatialQuery {
  gf::SpatialQuery::Contain,
  gf::SpatialQuery::Intersect
}
 A kind of spatial query. More...
 
enum  gf::Winding {
  gf::Winding::Clockwise,
  gf::Winding::Counterclockwise
}
 The direction of a polygon's rotation. 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< Vector2igf::generateLine (Vector2i p0, Vector2i p1)
 Generate a line between two positions. More...
 
std::vector< Vector2fgf::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< Vector2fgf::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< Vector2fgf::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...
 
constexpr gf::Id gf::literals::operator"" _id (const char *str, std::size_t sz)
 User defined operator for creating compile time ids from strings. 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 >
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...
 

Detailed Description

All the core generic classes and functions.

Typedef Documentation

◆ CircF

using gf::CircF = typedef Circ<float>

A float circle.

See also
gf::Circ

◆ CircI

using gf::CircI = typedef Circ<int>

A int circle.

See also
gf::Circ

◆ CircU

using gf::CircU = typedef Circ<unsigned>

A unsigned circle.

See also
gf::Circ

◆ CircZ

using gf::CircZ = typedef Circ<std::size_t>

A std::size_t circle.

See also
gf::Circ

◆ Color3f

using gf::Color3f = typedef Vector<float, 3>

A float color vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Color3u

using gf::Color3u = typedef Vector<uint8_t, 3>

A uint8_t color vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Color4f

using gf::Color4f = typedef Vector<float, 4>

A float color vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Color4u

using gf::Color4u = typedef Vector<uint8_t, 4>

A uint8_t color vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Distance

template<typename T , std::size_t N>
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.

gf::Distance<float, 3> distFn = gf::manhattanDistance<float, 3>;
Vector3f vec1 = ...;
Vector3f vec2 = ...;
float distance = distFn(vec1, vec2);
See also
manhattanDistance(), squareDistance(), euclideanDistance(), chebyshevDistance()
gf::Distance2, gf::Distance3

◆ Distance2

template<typename T >
using gf::Distance2 = typedef Distance<T, 2>

A distance function for 2D vectors.

See also
gf::Distance

◆ Distance3

template<typename T >
using gf::Distance3 = typedef Distance<T, 3>

A distance function for 3D vectors.

See also
gf::Distance

◆ Easing

using gf::Easing = typedef float (*)(float)

An easing function.

An easing function is a function that specifies how a value changes over time. A normalized easing function has the following properties:

  • \( f(0) = 0 \)
  • \( f(1) = 1 \)

Usual easing functions are provided in gf::Ease.

See also
gf::Ease, gf::Step

◆ Id

using gf::Id = typedef uint64_t

An identifier.

◆ Matrix2f

using gf::Matrix2f = typedef Matrix<float, 2, 2>

A float square matrix of size 2.

See also
gf::Matrix, gf::Matrix<T, 2, 2>

◆ Matrix3f

using gf::Matrix3f = typedef Matrix<float, 3, 3>

A float square matrix of size 3.

See also
gf::Matrix, gf::Matrix<T, 3, 3>

◆ Matrix4f

using gf::Matrix4f = typedef Matrix<float, 4, 4>

A float square matrix of size 4.

See also
gf::Matrix, gf::Matrix<T, 4, 4>

◆ Path

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.

◆ RangeF

using gf::RangeF = typedef Range<float>

A float range.

See also
gf::Range

◆ RangeI

using gf::RangeI = typedef Range<int>

A int range.

See also
gf::Range

◆ RangeU

using gf::RangeU = typedef Range<unsigned>

A unsigned range.

See also
gf::Range

◆ RangeZ

using gf::RangeZ = typedef Range<std::size_t>

A std::size_t range.

See also
gf::Range

◆ RectF

using gf::RectF = typedef Rect<float>

A float rectangle.

See also
gf::Rect

◆ RectI

using gf::RectI = typedef Rect<int>

A int rectangle.

See also
gf::Rect

◆ RectU

using gf::RectU = typedef Rect<unsigned>

A unsigned rectangle.

See also
gf::Rect

◆ RectZ

using gf::RectZ = typedef Rect<std::size_t>

A std::size_t rectangle.

See also
gf::Rect

◆ SpatialQueryCallback

template<typename T >
using gf::SpatialQueryCallback = typedef std::function<void(const T&)>

A callback for spatial query.

◆ Step

template<typename T >
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:

  • \( f(0) = 0 \)
  • \( f(1) = 1 \)

It can be used to smooth a linear interpolation.

gf::Vector2f point1 = ...;
gf::Vector2f point2 = ...;
float t = ...;
gf::Step<float> step = gf::cubicStep<float>;
gf::Vector2f interpolatedPoint = gf::lerp(point1, point2, t);
gf::Vector2f smoothedInterpolatedPoint = gf::lerp(point1, point2, step(t));
See also
linearStep(), cubicStep(), quinticStep(), cosineStep()

◆ Vector2b

using gf::Vector2b = typedef Vector<bool, 2>

A bool vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector2d

using gf::Vector2d = typedef Vector<double, 2>

A double vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector2f

using gf::Vector2f = typedef Vector<float, 2>

A float vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector2i

using gf::Vector2i = typedef Vector<int, 2>

A int vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector2u

using gf::Vector2u = typedef Vector<unsigned, 2>

A unsigned vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector2z

using gf::Vector2z = typedef Vector<std::size_t, 2>

A std::size_t vector with 2 components.

See also
gf::Vector, gf::Vector<T, 2>

◆ Vector3b

using gf::Vector3b = typedef Vector<bool, 3>

A bool vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector3d

using gf::Vector3d = typedef Vector<double, 3>

A double vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector3f

using gf::Vector3f = typedef Vector<float, 3>

A float vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector3i

using gf::Vector3i = typedef Vector<int, 3>

A int vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector3u

using gf::Vector3u = typedef Vector<unsigned, 3>

A unsigned vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector3z

using gf::Vector3z = typedef Vector<std::size_t, 3>

A std::size_t vector with 3 components.

See also
gf::Vector, gf::Vector<T, 3>

◆ Vector4b

using gf::Vector4b = typedef Vector<bool, 4>

A bool vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Vector4d

using gf::Vector4d = typedef Vector<double, 4>

A double vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Vector4f

using gf::Vector4f = typedef Vector<float, 4>

A float vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Vector4i

using gf::Vector4i = typedef Vector<int, 4>

A int vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Vector4u

using gf::Vector4u = typedef Vector<unsigned, 4>

A unsigned vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

◆ Vector4z

using gf::Vector4z = typedef Vector<std::size_t, 4>

A std::size_t vector with 4 components.

See also
gf::Vector, gf::Vector<T, 4>

Enumeration Type Documentation

◆ AngularMove

enum gf::AngularMove
strong

An angular move.

An angular move represents a rotation move to the right or to the left.

See also
gf::LinearMove
Enumerator
None 

No angular move.

Left 

Move to the left (i.e. counter-clockwise)

Right 

Move to the right (i.e. clockwise)

◆ Direction

enum gf::Direction : int
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.

See also
gf::Orientation
Enumerator
Center 

The center, indicates no direction.

Up 

The up direction.

Right 

The right direction.

Down 

The down direction.

Left 

The left direction.

◆ LinearMove

enum gf::LinearMove
strong

A linear move.

A linear move represents a translation move forward or backward.

See also
gf::AngularMove
Enumerator
None 

No linear move.

Forward 

Move forward.

Backward 

Move backward.

◆ Orientation

enum gf::Orientation : int
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.

See also
gf::Direction
Enumerator
Center 

The center, indicates no orientation.

North 

The north orientation.

NorthEast 

The north-east orientation.

East 

The east orientation.

SouthEast 

The south-east orientation.

South 

The south orientation.

SouthWest 

The south-west orientation.

West 

The west orientation.

NorthWest 

The north-west orientation.

◆ SpatialQuery

enum gf::SpatialQuery
strong

A kind of spatial query.

Enumerator
Contain 

Search for all objects that contain the given bounds.

Intersect 

Search for all objects that intersect the given bounds.

◆ Winding

enum gf::Winding
strong

The direction of a polygon's rotation.

Enumerator
Clockwise 

Same direction as a clock's hands.

Counterclockwise 

Opposite direction of a clock's hands.

Function Documentation

◆ absdiff()

template<typename T >
constexpr T gf::absdiff ( lhs,
rhs 
)

Absolute difference of two values.

This function is defined as:

\[ \text{absdiff}(a, b) = | a - b | \]

Parameters
lhsThe first value
rhsThe second value
Returns
The absolute difference between the two values

◆ almostEquals()

template<typename T >
bool gf::almostEquals ( a,
b,
epsilon = std::numeric_limits<T>::epsilon() 
)
inline

Compare two floats.

Parameters
aThe first float
bThe second float
epsilonA small value that controls the equality comparison
See also
Comparison - The Floating-Point Guide

◆ angle() [1/2]

float gf::angle ( Direction  direction)

Get an angle from a direction.

Up is at angle 0 and angle grows clockwise.

Parameters
directionThe direction
Returns
an angle (in radians) representing the direction

◆ angle() [2/2]

float gf::angle ( Orientation  orientation)

Get an angle from a orientation.

North is at angle 0 and angle grows clockwise.

Parameters
orientationThe orientation
Returns
an angle (in radians) representing the orientation

◆ angularFactor()

float gf::angularFactor ( AngularMove  move)

Get the angular factor from the angular move.

Returns
\( -1 \), \( 0 \) or \( 1 \) with respect to the move

◆ clamp()

template<typename T >
constexpr T gf::clamp ( val,
lo,
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.

Parameters
valThe value to clamp
loThe minimum accepted value
hiThe maximum accepted value
Returns
The clamped value

◆ computeUnicodeString()

std::u32string gf::computeUnicodeString ( StringRef  str)

Compute a UTF-32 string from a UTF-8 string.

Parameters
strA UTF-8 string
Returns
The corresponding UTF-32 string

◆ convexHull()

Polygon gf::convexHull ( ArrayRef< Vector2f points)

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

Parameters
pointsThe set of points
Returns
A (convex) polygon that contains the points

◆ cosineStep()

template<typename T >
T gf::cosineStep ( t)
inline

Cosine step.

\[ f(t) = (1 - \cos(\pi * t)) * 0.5 \]

See also
gf::Step

◆ cubicStep()

template<typename T >
constexpr T gf::cubicStep ( t)

Cubic step (smoothstep)

\[ f(t) = -2 * t^3 + 3 * t^2 \]

Compared to a step, it has the following properties:

  • \( f'(0) = 0 \)
  • \( f'(1) = 0 \)

This function is also known as smoothstep

See also
gf::Step

◆ degreesToRadians()

constexpr float gf::degreesToRadians ( float  degrees)

Convert degrees to radians.

Parameters
degreesAn angle in degrees
Returns
The angle in radians
See also
radiansToDegrees()

◆ diamondSquare2D()

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 \).

Parameters
sizeThe size of the map
randomA random engine
initialValuesThe initial values of the four corners
See also
gf::midpointDisplacement2D()

◆ displacement() [1/2]

Vector2i gf::displacement ( Direction  direction)

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.

Parameters
directionThe direction
Returns
A vector representing the direction

◆ displacement() [2/2]

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.

Parameters
orientationThe orientation
Returns
A vector representing the orientation

◆ formatString() [1/2]

std::string gf::formatString ( const char *  fmt,
  ... 
)

Format a string like printf.

Parameters
fmtThe format string

◆ formatString() [2/2]

std::string gf::formatString ( const char *  fmt,
va_list  ap 
)

Format a string like vprintf.

Parameters
fmtThe format string
apThe arguments of the format string

◆ generateLine()

std::vector<Vector2i> gf::generateLine ( Vector2i  p0,
Vector2i  p1 
)

Generate a line between two positions.

This function uses Bresenham's line algorithm.

Parameters
p0The first point of the line
p1The last point of the line
Returns
A series of point beginning at the first point and ending just before the last point
See also
gf::Bresenham

◆ hash() [1/2]

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:

gf::Id id = "A string"_id; // computed at compile time
Parameters
strThe string
szThe size of the string

◆ hash() [2/2]

constexpr Id gf::hash ( StringRef  str)

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.

Parameters
strThe string
Returns
The hash of the string

◆ identityTransform()

constexpr Matrix3f gf::identityTransform ( )

Identity transform.

Returns
The identity matrix

◆ lerp()

template<typename T , typename U >
constexpr T gf::lerp ( lhs,
rhs,
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.

Parameters
lhsThe first value
rhsThe second value
tThe interpolation parameter, generally in the interval \( [0,1] \)
Returns
A value between the first and second value

◆ linearFactor()

float gf::linearFactor ( LinearMove  move)

Get the linear factor from the linear move.

Returns
\( -1 \), \( 0 \) or \( 1 \) with respect to the move

◆ linearStep()

template<typename T >
constexpr T gf::linearStep ( t)

Linear step.

\[ f(t) = t \]

See also
gf::Step

◆ midpointDisplacement1D() [1/2]

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

Parameters
p0The first end point
p1The second end point
randomA random engine
iterationsThe number of iterations
directionThe direction to make a displacement
initialFactorThe initial factor to apply to the displacement
reductionFactorThe factor to apply at each iteration

◆ midpointDisplacement1D() [2/2]

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] \)

Parameters
p0The first end point
p1The second end point
randomA random engine
iterationsThe number of iterations
initialFactorThe initial factor to apply to the displacement
reductionFactorThe factor to apply at each iteration

◆ midpointDisplacement2D()

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 \).

Parameters
sizeThe size of the map
randomA random engine
initialValuesThe initial values of the four corners
See also
gf::diamondSquare2D()

◆ nextCCW() [1/2]

Direction gf::nextCCW ( Direction  direction)

Get the next direction counter-clockwise.

Parameters
directionThe direction
Returns
The next direction counter-clockwise

◆ nextCCW() [2/2]

Orientation gf::nextCCW ( Orientation  orientation)

Get the next orientation counter-clockwise.

Parameters
orientationThe orientation
Returns
The next orientation counter-clockwise

◆ nextCW() [1/2]

Direction gf::nextCW ( Direction  direction)

Get the next direction clockwise.

Parameters
directionThe direction
Returns
The next direction clockwise

◆ nextCW() [2/2]

Orientation gf::nextCW ( Orientation  orientation)

Get the next orientation clockwise.

Parameters
orientationThe orientation
Returns
The next orientation clockwise

◆ niceNum()

std::string gf::niceNum ( float  num,
float  precision 
)

Create a string representation of a floating point number.

It is based on Python niceNum.

Parameters
numThe number to display
precisionThe precision to use for display
Returns
A string representing the number

◆ operator"" _id()

constexpr gf::Id gf::literals::operator"" _id ( const char *  str,
std::size_t  sz 
)

User defined operator for creating compile time ids from strings.

To use it, you have to use the gf::literals namespace:

using namespace gf::literals;
Id id = "FooBar"_id;

◆ opposite() [1/2]

Direction gf::opposite ( Direction  direction)

Get the opposite direction.

Parameters
directionThe direction
Returns
The opposite direction

◆ opposite() [2/2]

Orientation gf::opposite ( Orientation  orientation)

Get the opposite orientation.

Parameters
orientationThe orientation
Returns
The opposite orientation

◆ orthogonalCCW() [1/2]

Direction gf::orthogonalCCW ( Direction  direction)

Get the orthogonal direction counter-clockwise.

Parameters
directionThe direction
Returns
The orthogonal direction counter-clockwise

◆ orthogonalCCW() [2/2]

Orientation gf::orthogonalCCW ( Orientation  orientation)

Get the orthogonal orientation counter-clockwise.

Parameters
orientationThe orientation
Returns
The orthogonal orientation counter-clockwise

◆ orthogonalCW() [1/2]

Direction gf::orthogonalCW ( Direction  direction)

Get the orthogonal direction clockwise.

Parameters
directionThe direction
Returns
The orthogonal direction clockwise

◆ orthogonalCW() [2/2]

Orientation gf::orthogonalCW ( Orientation  orientation)

Get the orthogonal orientation clockwise.

Parameters
orientationThe orientation
Returns
The orthogonal orientation clockwise

◆ quinticStep()

template<typename T >
constexpr T gf::quinticStep ( t)

Quintic step (smootherstep)

\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]

Compared to a step, it has the following properties:

  • \( f'(0) = 0 \)
  • \( f'(1) = 0 \)
  • \( f''(0) = 0 \)
  • \( f''(1) = 0 \)

This function is also known as smootherstep

See also
gf::Step

◆ radiansToDegrees()

constexpr float gf::radiansToDegrees ( float  radians)

Convert radians to degrees.

Parameters
radiansAn angle in radians
Returns
The angle in degrees
See also
degreesToRadians()

◆ rotate() [1/2]

void gf::rotate ( Matrix3f mat,
float  angle 
)

Combine the current transform with a rotation.

Parameters
matThe current transform
angleThe angle of the rotation (in radians)

◆ rotate() [2/2]

void gf::rotate ( Matrix3f mat,
float  angle,
Vector2f  center 
)

Combine the current transform with a rotation.

Parameters
matThe current transform
angleThe angle of the rotation (in radians)
centerThe center of the rotation

◆ rotation() [1/2]

Matrix3f gf::rotation ( float  angle)
inline

Get a rotation matrix.

Parameters
angleThe angle of the rotation (in radians)
Returns
A rotation of angle radians

◆ rotation() [2/2]

Matrix3f gf::rotation ( float  angle,
Vector2f  center 
)
inline

Get a rotation matrix.

Parameters
angleThe angle of the rotation (in radians)
centerThe center of the rotation
Returns
A rotation of angle radians of origin center

◆ scale() [1/2]

void gf::scale ( Matrix3f mat,
Vector2f  factor 
)

Combine the current transform with a scaling.

Parameters
matThe current transform
factorThe scaling factor

◆ scale() [2/2]

void gf::scale ( Matrix3f mat,
Vector2f  factor,
Vector2f  center 
)

Combine the current transform with a scaling.

Parameters
matThe current transform
factorThe scaling factor
centerThe center of the scaling

◆ scaling() [1/2]

Matrix3f gf::scaling ( Vector2f  factor)
inline

Get a scaling matrix.

Parameters
factorThe scaling factor
Returns
A scaling by factor

◆ scaling() [2/2]

Matrix3f gf::scaling ( Vector2f  factor,
Vector2f  center 
)
inline

Get a scaling matrix.

Parameters
factorThe scaling factor
centerThe center of the scaling
Returns
A scaling by factor of origin center

◆ sign()

template<typename T >
constexpr int gf::sign ( val)

Sign function.

The sign function of \( x \) is:

  • \( -1 \) if \( x < 0 \)
  • \( 0 \) if \( x = 0 \)
  • \( 1 \) if \( x > 0 \)
Parameters
valA value
Returns
The sign of the value
See also
Sign function

◆ simplifyPoints()

std::vector<Vector2f> gf::simplifyPoints ( ArrayRef< Vector2f points,
float  distance = Epsilon 
)

Simplify a sequence of points.

This function uses the Douglas–Peucker algorithm.

Parameters
pointsThe sequence of points
distanceThe maximum authorized distance between the original points and the simplified points
Returns
A new simplified sequence of points

◆ sleep()

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.

Parameters
durationThe time to sleep

◆ splitInParagraphs()

std::vector<std::u32string> gf::splitInParagraphs ( const std::u32string &  str)

◆ square()

template<typename T >
constexpr T gf::square ( val)

Square function.

For a value \( x \), the square value is \( x^2 \).

Parameters
valA value
Returns
The square of the value

◆ transform() [1/2]

constexpr Vector2f gf::transform ( const Matrix3f mat,
Vector2f  point 
)

Apply an affine transformation to a 2D point.

Parameters
matThe transformation matrix
pointThe point to transform
Returns
The transformed point

◆ transform() [2/2]

RectF gf::transform ( const Matrix3f mat,
const RectF rect 
)

Apply an affine transformaton to a rectangle.

The resulting rectangle is axis-aligned

Parameters
matThe transformation matrix
rectThe rectangle to transform
Returns
The transformed rectangle

◆ translate()

void gf::translate ( Matrix3f mat,
Vector2f  offset 
)

Combine the current transform with a translation.

Parameters
matThe current transform
offsetThe offset of the translation

◆ translation()

Matrix3f gf::translation ( Vector2f  offset)
inline

Get a translation matrix.

Parameters
offsetThe offset of the translation
Returns
A translation by offset

◆ triangulation()

std::vector<TriangleRef<const Vector2f> > gf::triangulation ( ArrayRef< Vector2f points)

Compute a Delaunay triangulation of a set of points.

Parameters
pointsThe set of points
Returns
A set of triangles refering to the original points

◆ unit() [1/2]

Vector2f gf::unit ( Direction  direction)

Get a unit vector from a direction.

Parameters
directionThe direction
Returns
A unit vector representing the direction

◆ unit() [2/2]

Vector2f gf::unit ( Orientation  orientation)

Get a unit vector from an orientation.

Parameters
orientationThe orientation
Returns
A unit vector representing the orientation

◆ unused()

template<typename... Args>
void gf::unused ( Args &&  ...)
inline

A simple way to avoid warnings about unused variables.

Variable Documentation

◆ All

constexpr AllType gf::All = { }

Constant to represent "all".

See also
gf::AllType, gf::None

◆ Epsilon

constexpr float gf::Epsilon = std::numeric_limits<float>::epsilon()

Machine epsilon.

◆ InvalidId

constexpr Id gf::InvalidId = 0

The invalid id (which is 0)

◆ InvSqrt2

constexpr float gf::InvSqrt2 = 1 / Sqrt2

The \( \frac{1}{\sqrt{2}} \) constant.

◆ None

constexpr NoneType gf::None = { }

Constant to represent "none".

See also
gf::NoneType, gf::All

◆ Pi

constexpr float gf::Pi = 3.14159265358979323846f

The \( \pi \) constant.

◆ Pi2

constexpr float gf::Pi2 = Pi / 2

The \( \frac{\pi}{2} \) constant.

◆ Pi4

constexpr float gf::Pi4 = Pi / 4

The \( \frac{\pi}{4} \) constant.

◆ Sqrt2

constexpr float gf::Sqrt2 = 1.41421356237309504880f

The \( \sqrt{2} \) constant.

◆ Sqrt3

constexpr float gf::Sqrt3 = 1.7320508075688772935f

The \( \sqrt{3} \) constant.

◆ Zero

constexpr ZeroType gf::Zero = { }

Constant to represent "zero".

See also
gf::ZeroType