4#include <SDL3_image/SDL_image.h>
5#include <SDL3_ttf/SDL_ttf.h>
42 SDL_FlipMode flip = SDL_FLIP_NONE;
45 flip =
static_cast<SDL_FlipMode
>(flip | SDL_FLIP_HORIZONTAL);
49 flip =
static_cast<SDL_FlipMode
>(flip | SDL_FLIP_VERTICAL);
61 dest.w = position.
size.x;
62 dest.h = position.
size.y;
79 angle,
nullptr, SDL_FLIP_NONE);
88 r_src.w = source.
size.x;
89 r_src.h = source.
size.y;
94 r_dest.w = dest.
size.x;
95 r_dest.h = dest.
size.y;
107 r_src.w = source.
size.x;
108 r_src.h = source.
size.y;
113 r_dest.w = dest.
size.x;
114 r_dest.h = dest.
size.y;
117 angle,
nullptr, SDL_FLIP_NONE);
121 const std::string& text,
128 const SDL_Color sdlColor =
130 SDL_Surface* textSurface =
131 TTF_RenderText_Solid(font.get(),
text.c_str(), 0, sdlColor);
132 SDL_Texture* textTexture =
138 dest.w = float(textSurface->w);
139 dest.h = float(textSurface->h);
142 SDL_DestroySurface(textSurface);
143 SDL_DestroyTexture(textTexture);
147 const std::string& text,
156 const std::string& text,
207 for (
int i = 0; i < 360; i++) {
209 position.
x +
static_cast<float>(radius * std::cos(i)),
210 position.
y +
static_cast<float>(radius * std::sin(i)));
219 for (
int i = 0; i < 360; i++) {
221 position.
x +
static_cast<float>(radius * std::cos(i)),
222 position.
y +
static_cast<float>(radius * std::sin(i)));
227 SDL_SetTextureBlendMode(texture.get(),
static_cast<SDL_BlendMode
>(mode));
231 SDL_SetTextureAlphaModFloat(texture.get(), alpha);
Vec2< T > size
The size of the rectangle.
Vec2< T > position
The position of the rectangle.
T y
The y component of the vector.
T x
The x component of the vector.
Display and window routines for the ASW library.
Routines for drawing sprites and primitives to the screen.
asw::Renderer * renderer
The renderer for the display module.
void setBlendMode(const asw::Texture &texture, asw::BlendMode mode)
Set the blend mode of a texture.
void sprite(const asw::Texture &tex, const asw::Vec2< float > &position)
Draw a sprite.
void stretchSprite(const asw::Texture &tex, const asw::Quad< float > &position)
Draw a sprite with the option to stretch it.
void rotateSprite(const asw::Texture &tex, const asw::Vec2< float > &position, double angle)
Draw a sprite with the option to rotate it.
void stretchSpriteRotateBlit(const asw::Texture &tex, const asw::Quad< float > &source, const asw::Quad< float > &dest, double angle)
Draw a sprite with the option to stretch and rotate a portion of it.
void textCenter(const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color)
Draw text center aligned.
void line(const asw::Vec2< float > &position1, const asw::Vec2< float > &position2, asw::Color color)
Draw a line.
void rectFill(const asw::Quad< float > &position, asw::Color color)
Draw a filled rectangle.
void stretchSpriteBlit(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 setAlpha(const asw::Texture &texture, float alpha)
Set the alpha of a texture.
void rect(const asw::Quad< float > &position, asw::Color color)
Draw a rectangle.
void circle(const asw::Vec2< float > &position, float radius, asw::Color color)
Draw a circle.
void spriteFlip(const asw::Texture &tex, const asw::Vec2< float > &position, bool flipX, bool flipY)
Draw a sprite with the option to flip it.
void circleFill(const asw::Vec2< float > &position, float radius, asw::Color color)
Draw a filled circle.
void point(const asw::Vec2< float > &position, asw::Color color)
Draw a point.
void textRight(const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color)
Draw text right aligned.
void clearColor(asw::Color color)
Clear the screen to a color.
void text(const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color)
Draw text left aligned.
asw::Vec2< float > getTextureSize(const asw::Texture &tex)
Get texture size.
asw::Color makeColor(int r, int g, int b)
Make a color from RGB values.
asw::Vec2< int > getTextSize(const asw::Font &font, const std::string &text)
Get text size.
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
BlendMode
Mappings from SDL_BLENDMODE to ASW BlendMode.
SDL_Color Color
Alias for an SDL_Color.
General utility functions.