ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
8
9#ifndef ASW_UTIL_H
10#define ASW_UTIL_H
11
12#include <algorithm>
13#include <string>
14
15#include "./geometry.h"
16#include "./types.h"
17
18namespace asw::util {
19
24 void abortOnError(const std::string& message);
25
33 asw::Color makeColor(int r, int g, int b);
34
43 asw::Color makeColor(int r, int g, int b, int a);
44
51
58 asw::Vec2<int> getTextSize(const asw::Font& font, const std::string& text);
59
67 template <typename T>
68 T lerp(const T& a, const T& b, float t) {
69 t = std::clamp(t, 0.0F, 1.0F);
70
71 return a + (b - a) * t;
72 }
73
74} // namespace asw::util
75
76#endif // ASW_UTIL_H
A 2D vector in space.
Definition geometry.h:22
Common geometry types.
asw::Vec2< float > getTextureSize(const asw::Texture &tex)
Get texture size.
Definition util.cpp:30
asw::Color makeColor(int r, int g, int b)
Make a color from RGB values.
Definition util.cpp:12
asw::Vec2< int > getTextSize(const asw::Font &font, const std::string &text)
Get text size.
Definition util.cpp:36
void abortOnError(const std::string &message)
Abort program and display error message.
Definition util.cpp:6
T lerp(const T &a, const T &b, float t)
Lerp between two values.
Definition util.h:68
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:23
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:20
SDL_Color Color
Alias for an SDL_Color.
Definition types.h:38
Types used throughout the ASW library.