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
asw::util Namespace Reference

Functions

void abort_on_error (const std::string &message)
 Abort program and display error message.
 
asw::Vec2< float > get_texture_size (const asw::Texture &tex)
 Get texture size.
 
asw::Vec2< int > get_text_size (const asw::Font &font, std::string_view text)
 Get text size.
 
int get_font_height (const asw::Font &font)
 Get the height of a line of text in a font.
 
bool open_url (const std::string &url)
 Open a web page in the player's browser, e.g. a login or store page. Web builds open it in a new tab.
 
void clear_text_size_cache ()
 Clear cached text metrics.
 
template<typename T >
T lerp (const T &a, const T &b, float t)
 Lerp between two values.
 

Function Documentation

◆ abort_on_error()

void asw::util::abort_on_error ( const std::string & message)

Abort program and display error message.

Parameters
messageMessage to display

Definition at line 67 of file util.cpp.

◆ clear_text_size_cache()

void asw::util::clear_text_size_cache ( )

Clear cached text metrics.

Text size caching is shared across widgets and text drawing helpers, so it should be cleared when font resources are unloaded.

Definition at line 115 of file util.cpp.

◆ get_font_height()

int asw::util::get_font_height ( const asw::Font & font)

Get the height of a line of text in a font.

Parameters
fontFont to use
Returns
Line height in pixels, 0 if the font is not loaded

Definition at line 106 of file util.cpp.

◆ get_text_size()

asw::Vec2< int > asw::util::get_text_size ( const asw::Font & font,
std::string_view text )

Get text size.

Parameters
fontFont to use
textText to get size of
Returns
Size as Vec2

Definition at line 81 of file util.cpp.

◆ get_texture_size()

asw::Vec2< float > asw::util::get_texture_size ( const asw::Texture & tex)

Get texture size.

Parameters
texTexture to get size of
Returns
Size as Vec2

Definition at line 74 of file util.cpp.

◆ lerp()

template<typename T >
T asw::util::lerp ( const T & a,
const T & b,
float t )

Lerp between two values.

Parameters
aStart value
bEnd value
tInterpolation value (0-1)
Returns
Interpolated value

Definition at line 73 of file util.h.

◆ open_url()

bool asw::util::open_url ( const std::string & url)

Open a web page in the player's browser, e.g. a login or store page. Web builds open it in a new tab.

Parameters
urlThe address to open.
Returns
true - If the browser was asked to open it.

Definition at line 120 of file util.cpp.