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
Go to the documentation of this file.
1
8
9#ifndef ASW_DRAW_H
10#define ASW_DRAW_H
11
12#include <string>
13
14#include "./color.h"
15#include "./geometry.h"
16#include "./types.h"
17
18namespace asw::draw {
19
24void clear_color(asw::Color color);
25
31void sprite(const asw::Texture& tex, const asw::Vec2<float>& position);
32
40void sprite_flip(
41 const asw::Texture& tex, const asw::Vec2<float>& position, bool flip_x, bool flip_y);
42
49void stretch_sprite(const asw::Texture& tex, const asw::Quad<float>& position);
50
57void rotate_sprite(const asw::Texture& tex, const asw::Vec2<float>& position, float angle);
58
69void stretch_sprite_rotate(const asw::Texture& tex, const asw::Quad<float>& dest, float angle,
70 bool flip_x = false, bool flip_y = false);
71
80 const asw::Texture& tex, const asw::Quad<float>& source, const asw::Quad<float>& dest);
81
93void stretch_sprite_rotate_blit(const asw::Texture& tex, const asw::Quad<float>& source,
94 const asw::Quad<float>& dest, float angle, bool flip_x = false, bool flip_y = false);
95
107void text(const asw::Font& font, const std::string& text, const asw::Vec2<float>& position,
109
121void text_shadow(const asw::Font& font, const std::string& text, const asw::Vec2<float>& position,
122 asw::Color color, asw::Color shadow = asw::Color(0, 0, 0),
123 const asw::Vec2<float>& offset = asw::Vec2<float>(2.0F, 2.0F),
125
131void clear_text_cache();
132
138void point(const asw::Vec2<float>& position, asw::Color color);
139
146void line(const asw::Vec2<float>& position1, const asw::Vec2<float>& position2, asw::Color color);
147
154void rect(const asw::Quad<float>& position, asw::Color color, float thickness = 1.0F);
155
161void rect_fill(const asw::Quad<float>& position, asw::Color color);
162
171void rect_fill_rotate(const asw::Quad<float>& position, float angle, asw::Color color);
172
179void circle(const asw::Vec2<float>& position, float radius, asw::Color color);
180
187void circle_fill(const asw::Vec2<float>& position, float radius, asw::Color color);
188
196void triangle_fill(const asw::Vec2<float>& a, const asw::Vec2<float>& b, const asw::Vec2<float>& c,
197 asw::Color color);
198
204void polygon(const asw::Polygonf& points, asw::Color color);
205
212void polygon_fill(const asw::Polygonf& points, asw::Color color);
213
219void set_blend_mode(const asw::Texture& texture, asw::BlendMode mode);
220
226void set_alpha(const asw::Texture& texture, float alpha);
227
235void set_tint(const asw::Texture& texture, asw::Color tint);
236
243void set_scale_mode(const asw::Texture& texture, asw::ScaleMode mode);
244} // namespace asw::draw
245
246#endif // ASW_DRAW_H
A 2D rectangle in space.
Definition geometry.h:504
A 2D vector in space.
Definition geometry.h:27
Common geometry types.
void sprite(const asw::Texture &tex, const asw::Vec2< float > &position)
Draw a sprite.
Definition draw.cpp:185
void circle_fill(const asw::Vec2< float > &position, float radius, asw::Color color)
Draw a filled circle.
Definition draw.cpp:647
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.
Definition draw.cpp:270
void polygon(const asw::Polygonf &points, asw::Color color)
Draw the outline of a polygon. The last point joins the first.
Definition draw.cpp:694
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 i...
Definition draw.cpp:833
void clear_color(asw::Color color)
Clear the screen to a color.
Definition draw.cpp:174
void rect(const asw::Quad< float > &position, asw::Color color, float thickness=1.0F)
Draw a rectangle.
Definition draw.cpp:504
void line(const asw::Vec2< float > &position1, const asw::Vec2< float > &position2, asw::Color color)
Draw a line.
Definition draw.cpp:492
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.
Definition draw.cpp:676
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,...
Definition draw.cpp:828
void rotate_sprite(const asw::Texture &tex, const asw::Vec2< float > &position, float angle)
Draw a sprite with the option to rotate it.
Definition draw.cpp:248
void stretch_sprite(const asw::Texture &tex, const asw::Quad< float > &position)
Draw a sprite with the option to stretch it.
Definition draw.cpp:232
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...
Definition draw.cpp:464
void clear_text_cache()
Clear cached rendered text textures.
Definition draw.cpp:475
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....
Definition draw.cpp:357
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.
Definition draw.cpp:712
void circle(const asw::Vec2< float > &position, float radius, asw::Color color)
Draw a circle.
Definition draw.cpp:589
void rect_fill(const asw::Quad< float > &position, asw::Color color)
Draw a filled rectangle.
Definition draw.cpp:536
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.
Definition draw.cpp:203
void point(const asw::Vec2< float > &position, asw::Color color)
Draw a point.
Definition draw.cpp:481
void set_blend_mode(const asw::Texture &texture, asw::BlendMode mode)
Set the blend mode of a texture.
Definition draw.cpp:818
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.
Definition draw.cpp:300
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.
Definition draw.cpp:323
void set_alpha(const asw::Texture &texture, float alpha)
Set the alpha of a texture.
Definition draw.cpp:823
void rect_fill_rotate(const asw::Quad< float > &position, float angle, asw::Color color)
Draw a filled rectangle rotated around its centre.
Definition draw.cpp:553
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:79
Polygon< float > Polygonf
Definition geometry.h:741
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:76
BlendMode
Mappings from SDL_BLENDMODE to ASW BlendMode.
Definition types.h:26
ScaleMode
Mappings from SDL_SCALEMODE to ASW ScaleMode.
Definition types.h:40
TextJustify
Text justification options for text rendering.
Definition types.h:58
RGBA color struct with 8-bit channels.
Definition color.h:18
Types used throughout the ASW library.