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
draw.h File Reference

Routines for drawing sprites and primitives to the screen. More...

#include <string>
#include "./color.h"
#include "./geometry.h"
#include "./types.h"
Include dependency graph for draw.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  asw
 
namespace  asw::draw
 

Functions

void asw::draw::clear_color (asw::Color color)
 Clear the screen to a color.
 
void asw::draw::sprite (const asw::Texture &tex, const asw::Vec2< float > &position)
 Draw a sprite.
 
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.
 
void asw::draw::stretch_sprite (const asw::Texture &tex, const asw::Quad< float > &position)
 Draw a sprite with the option to stretch it.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void asw::draw::clear_text_cache ()
 Clear cached rendered text textures.
 
void asw::draw::point (const asw::Vec2< float > &position, asw::Color color)
 Draw a point.
 
void asw::draw::line (const asw::Vec2< float > &position1, const asw::Vec2< float > &position2, asw::Color color)
 Draw a line.
 
void asw::draw::rect (const asw::Quad< float > &position, asw::Color color, float thickness=1.0F)
 Draw a rectangle.
 
void asw::draw::rect_fill (const asw::Quad< float > &position, asw::Color color)
 Draw a filled rectangle.
 
void asw::draw::rect_fill_rotate (const asw::Quad< float > &position, float angle, asw::Color color)
 Draw a filled rectangle rotated around its centre.
 
void asw::draw::circle (const asw::Vec2< float > &position, float radius, asw::Color color)
 Draw a circle.
 
void asw::draw::circle_fill (const asw::Vec2< float > &position, float radius, asw::Color color)
 Draw a filled circle.
 
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.
 
void asw::draw::polygon (const asw::Polygonf &points, asw::Color color)
 Draw the outline of a polygon. The last point joins the first.
 
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.
 
void asw::draw::set_blend_mode (const asw::Texture &texture, asw::BlendMode mode)
 Set the blend mode of a texture.
 
void asw::draw::set_alpha (const asw::Texture &texture, float alpha)
 Set the alpha of a texture.
 
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.
 
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.
 

Detailed Description

Routines for drawing sprites and primitives to the screen.

Author
Allan Legemaate (alege.nosp@m.maat.nosp@m.e@gma.nosp@m.il.c.nosp@m.om)
Date
2023-09-20

Definition in file draw.h.