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::draw Namespace Reference

Functions

void clear_color (asw::Color color)
 Clear the screen to a color.
 
void sprite (const asw::Texture &tex, const asw::Vec2< float > &position)
 Draw a sprite.
 
void sprite_flip (const asw::Texture &tex, const asw::Vec2< float > &position, bool flip_x, bool flip_y)
 Draw a sprite with the option to flip it.
 
void stretch_sprite (const asw::Texture &tex, const asw::Quad< float > &position)
 Draw a sprite with the option to stretch it.
 
void rotate_sprite (const asw::Texture &tex, const asw::Vec2< float > &position, float angle)
 Draw a sprite with the option to rotate it.
 
void stretch_sprite_rotate (const asw::Texture &tex, const asw::Quad< float > &dest, float angle, bool flip_x=false, bool flip_y=false)
 Draw a sprite stretched to a quad, rotated around its centre and optionally flipped.
 
void stretch_sprite_blit (const asw::Texture &tex, const asw::Quad< float > &source, const asw::Quad< float > &dest)
 Draw a sprite with the option to stretch a portion of it.
 
void stretch_sprite_rotate_blit (const asw::Texture &tex, const asw::Quad< float > &source, const asw::Quad< float > &dest, float angle, bool flip_x=false, bool flip_y=false)
 Draw a sprite with the option to stretch and rotate a portion of it.
 
void text (const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color, asw::TextJustify justify=asw::TextJustify::Left)
 Draw text. The position is rounded to whole pixels after justification so glyphs stay sharp. Smooth fonts are rendered at the output resolution, so text stays sharp when the window is scaled up or on high density displays.
 
void text_shadow (const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color, asw::Color shadow=asw::Color(0, 0, 0), const asw::Vec2< float > &offset=asw::Vec2< float >(2.0F, 2.0F), asw::TextJustify justify=asw::TextJustify::Left)
 Draw text with a drop shadow behind it, so it reads on any background. The shadow fades with the text colour's alpha.
 
void clear_text_cache ()
 Clear cached rendered text textures.
 
void point (const asw::Vec2< float > &position, asw::Color color)
 Draw a point.
 
void line (const asw::Vec2< float > &position1, const asw::Vec2< float > &position2, asw::Color color)
 Draw a line.
 
void rect (const asw::Quad< float > &position, asw::Color color, float thickness=1.0F)
 Draw a rectangle.
 
void rect_fill (const asw::Quad< float > &position, asw::Color color)
 Draw a filled rectangle.
 
void rect_fill_rotate (const asw::Quad< float > &position, float angle, asw::Color color)
 Draw a filled rectangle rotated around its centre.
 
void circle (const asw::Vec2< float > &position, float radius, asw::Color color)
 Draw a circle.
 
void circle_fill (const asw::Vec2< float > &position, float radius, asw::Color color)
 Draw a filled circle.
 
void triangle_fill (const asw::Vec2< float > &a, const asw::Vec2< float > &b, const asw::Vec2< float > &c, asw::Color color)
 Draw a filled triangle.
 
void polygon (const asw::Polygonf &points, asw::Color color)
 Draw the outline of a polygon. The last point joins the first.
 
void polygon_fill (const asw::Polygonf &points, asw::Color color)
 Draw a filled polygon. The polygon can be concave, but its edges must not cross.
 
void set_blend_mode (const asw::Texture &texture, asw::BlendMode mode)
 Set the blend mode of a texture.
 
void set_alpha (const asw::Texture &texture, float alpha)
 Set the alpha of a texture.
 
void set_tint (const asw::Texture &texture, asw::Color tint)
 Set the tint of a texture. Each colour channel is multiplied by the tint when drawn, white draws the texture unchanged. Alpha is ignored, use set_alpha for transparency.
 
void set_scale_mode (const asw::Texture &texture, asw::ScaleMode mode)
 Set the scale mode of a texture. Nearest keeps hard pixel edges, linear smooths the texture when it is scaled.
 

Function Documentation

◆ circle()

void asw::draw::circle ( const asw::Vec2< float > & position,
float radius,
asw::Color color )

Draw a circle.

Parameters
positionThe position of the center of the circle.
radiusThe radius of the circle.
colorThe color of the circle.

Definition at line 589 of file draw.cpp.

◆ circle_fill()

void asw::draw::circle_fill ( const asw::Vec2< float > & position,
float radius,
asw::Color color )

Draw a filled circle.

Parameters
positionThe position of the center of the circle.
radiusThe radius of the circle.
colorThe color of the circle.

Definition at line 647 of file draw.cpp.

◆ clear_color()

void asw::draw::clear_color ( asw::Color color)

Clear the screen to a color.

Parameters
colorThe color to clear the screen to.

Definition at line 174 of file draw.cpp.

◆ clear_text_cache()

void asw::draw::clear_text_cache ( )

Clear cached rendered text textures.

Cached text depends on the active renderer and font resources, so shutdown paths clear it explicitly before SDL teardown.

Definition at line 475 of file draw.cpp.

◆ line()

void asw::draw::line ( const asw::Vec2< float > & position1,
const asw::Vec2< float > & position2,
asw::Color color )

Draw a line.

Parameters
position1The starting position of the line.
position2The ending position of the line.
colorThe color of the line.

Definition at line 492 of file draw.cpp.

◆ point()

void asw::draw::point ( const asw::Vec2< float > & position,
asw::Color color )

Draw a point.

Parameters
positionThe position of the point.
colorThe color of the point.

Definition at line 481 of file draw.cpp.

◆ polygon()

void asw::draw::polygon ( const asw::Polygonf & points,
asw::Color color )

Draw the outline of a polygon. The last point joins the first.

Parameters
pointsThe corners, in order.
colorThe color of the outline.

Definition at line 694 of file draw.cpp.

◆ polygon_fill()

void asw::draw::polygon_fill ( const asw::Polygonf & points,
asw::Color color )

Draw a filled polygon. The polygon can be concave, but its edges must not cross.

Parameters
pointsThe corners, in order, either way round.
colorThe color of the polygon.

Definition at line 712 of file draw.cpp.

◆ rect()

void asw::draw::rect ( const asw::Quad< float > & position,
asw::Color color,
float thickness = 1.0F )

Draw a rectangle.

Parameters
positionThe quad defining the position and size of the rectangle.
colorThe color of the rectangle.
thicknessWidth of the outline in pixels, drawn inside the quad.

Definition at line 504 of file draw.cpp.

◆ rect_fill()

void asw::draw::rect_fill ( const asw::Quad< float > & position,
asw::Color color )

Draw a filled rectangle.

Parameters
positionThe quad defining the position and size of the rectangle.
colorThe color of the rectangle.

Definition at line 536 of file draw.cpp.

◆ rect_fill_rotate()

void asw::draw::rect_fill_rotate ( const asw::Quad< float > & position,
float angle,
asw::Color color )

Draw a filled rectangle rotated around its centre.

Parameters
positionThe quad defining the position and size of the rectangle before rotation.
angleThe angle to rotate the rectangle by in radians, clockwise like the sprite rotation functions.
colorThe color of the rectangle.

Definition at line 553 of file draw.cpp.

◆ rotate_sprite()

void asw::draw::rotate_sprite ( const asw::Texture & tex,
const asw::Vec2< float > & position,
float angle )

Draw a sprite with the option to rotate it.

Parameters
texThe texture to draw.
positionThe position to draw the sprite at.
angleThe angle to rotate the sprite by in radians.

Definition at line 248 of file draw.cpp.

◆ set_alpha()

void asw::draw::set_alpha ( const asw::Texture & texture,
float alpha )

Set the alpha of a texture.

Parameters
textureThe texture to set the alpha of.
alphaThe alpha to set.

Definition at line 823 of file draw.cpp.

◆ set_blend_mode()

void asw::draw::set_blend_mode ( const asw::Texture & texture,
asw::BlendMode mode )

Set the blend mode of a texture.

Parameters
textureThe texture to set the blend mode of.
modeThe blend mode to set.

Definition at line 818 of file draw.cpp.

◆ set_scale_mode()

void asw::draw::set_scale_mode ( const asw::Texture & texture,
asw::ScaleMode mode )

Set the scale mode of a texture. Nearest keeps hard pixel edges, linear smooths the texture when it is scaled.

Parameters
textureThe texture to set the scale mode of.
modeThe scale mode to set.

Definition at line 833 of file draw.cpp.

◆ set_tint()

void asw::draw::set_tint ( const asw::Texture & texture,
asw::Color tint )

Set the tint of a texture. Each colour channel is multiplied by the tint when drawn, white draws the texture unchanged. Alpha is ignored, use set_alpha for transparency.

Parameters
textureThe texture to tint.
tintThe tint colour.

Definition at line 828 of file draw.cpp.

◆ sprite()

void asw::draw::sprite ( const asw::Texture & tex,
const asw::Vec2< float > & position )

Draw a sprite.

Parameters
texThe texture to draw.
positionThe position to draw the sprite at.

Definition at line 185 of file draw.cpp.

◆ sprite_flip()

void asw::draw::sprite_flip ( const asw::Texture & tex,
const asw::Vec2< float > & position,
bool flip_x,
bool flip_y )

Draw a sprite with the option to flip it.

Parameters
texThe texture to draw.
positionThe position to draw the sprite at.
flip_xWhether or not to flip the sprite on the x axis.
flip_yWhether or not to flip the sprite on the y axis.

Definition at line 203 of file draw.cpp.

◆ stretch_sprite()

void asw::draw::stretch_sprite ( const asw::Texture & tex,
const asw::Quad< float > & position )

Draw a sprite with the option to stretch it.

Parameters
texThe texture to draw.
positionThe quad defining the position and size to stretch the sprite to.

Definition at line 232 of file draw.cpp.

◆ stretch_sprite_blit()

void asw::draw::stretch_sprite_blit ( const asw::Texture & tex,
const asw::Quad< float > & source,
const asw::Quad< float > & dest )

Draw a sprite with the option to stretch a portion of it.

Parameters
texThe texture to draw.
sourceThe quad defining the portion of the texture to stretch.
destThe quad defining the position and size to stretch the sprite to.

Definition at line 300 of file draw.cpp.

◆ stretch_sprite_rotate()

void asw::draw::stretch_sprite_rotate ( const asw::Texture & tex,
const asw::Quad< float > & dest,
float angle,
bool flip_x = false,
bool flip_y = false )

Draw a sprite stretched to a quad, rotated around its centre and optionally flipped.

Parameters
texThe texture to draw.
destThe quad defining the position and size to stretch the sprite to.
angleThe angle to rotate the sprite by in radians.
flip_xWhether or not to flip the sprite on the x axis.
flip_yWhether or not to flip the sprite on the y axis.

Definition at line 270 of file draw.cpp.

◆ stretch_sprite_rotate_blit()

void asw::draw::stretch_sprite_rotate_blit ( const asw::Texture & tex,
const asw::Quad< float > & source,
const asw::Quad< float > & dest,
float angle,
bool flip_x = false,
bool flip_y = false )

Draw a sprite with the option to stretch and rotate a portion of it.

Parameters
texThe texture to draw.
sourceThe quad defining the portion of the texture to stretch.
destThe quad defining the position and size to stretch the sprite to.
angleThe angle to rotate the sprite by in radians.
flip_xWhether or not to flip the sprite on the x axis.
flip_yWhether or not to flip the sprite on the y axis.

Definition at line 323 of file draw.cpp.

◆ text()

void asw::draw::text ( const asw::Font & font,
const std::string & text,
const asw::Vec2< float > & position,
asw::Color color,
asw::TextJustify justify = asw::TextJustify::Left )

Draw text. The position is rounded to whole pixels after justification so glyphs stay sharp. Smooth fonts are rendered at the output resolution, so text stays sharp when the window is scaled up or on high density displays.

Parameters
fontThe font to use.
textThe text to draw.
positionThe position to draw the text at.
colorThe color to draw the text.
justifyThe justification of the text.

Definition at line 357 of file draw.cpp.

◆ text_shadow()

void asw::draw::text_shadow ( const asw::Font & font,
const std::string & text,
const asw::Vec2< float > & position,
asw::Color color,
asw::Color shadow = asw::Color(0, 0, 0),
const asw::Vec2< float > & offset = asw::Vec2<float>(2.0F, 2.0F),
asw::TextJustify justify = asw::TextJustify::Left )

Draw text with a drop shadow behind it, so it reads on any background. The shadow fades with the text colour's alpha.

Parameters
fontThe font to use.
textThe text to draw.
positionThe position to draw the text at.
colorThe color of the text.
shadowThe color of the shadow.
offsetHow far the shadow sits from the text.
justifyThe justification of the text.

Definition at line 464 of file draw.cpp.

◆ triangle_fill()

void asw::draw::triangle_fill ( const asw::Vec2< float > & a,
const asw::Vec2< float > & b,
const asw::Vec2< float > & c,
asw::Color color )

Draw a filled triangle.

Parameters
aThe first corner.
bThe second corner.
cThe third corner.
colorThe color of the triangle.

Definition at line 676 of file draw.cpp.