rename scale option to stretch

This commit is contained in:
veclav talica 2024-08-01 01:25:23 +03:00
parent b35c02d884
commit 9d2aa9b9ba
3 changed files with 5 additions and 3 deletions

View File

@ -57,7 +57,7 @@ static void ingame_tick(struct state *state) {
m_sprite(m_set(path, "/assets/player/baron-walk.png"), m_sprite(m_set(path, "/assets/player/baron-walk.png"),
m_set(rect, ((t_frect){ 256, 256, 48, 48 })), m_set(rect, ((t_frect){ 256, 256, 48, 48 })),
m_opt(color, ((t_color){ 255, 255, 255, 255 })), m_opt(color, ((t_color){ 255, 255, 255, 255 })),
m_opt(scale, false ), m_opt(stretch, false ),
m_opt(texture_origin, ((t_fvec2){ ctx.tick_count % 48, ctx.tick_count % 48 }))); m_opt(texture_origin, ((t_fvec2){ ctx.tick_count % 48, ctx.tick_count % 48 })));
m_sprite(m_set(path, "/assets/light.png"), m_sprite(m_set(path, "/assets/light.png"),

View File

@ -19,7 +19,7 @@ typedef struct push_sprite_args {
float, rotation, float, rotation,
bool, flip_x, bool, flip_x,
bool, flip_y, bool, flip_y,
bool, scale ) bool, stretch )
} t_push_sprite_args; } t_push_sprite_args;
/* pushes a sprite onto the sprite render queue */ /* pushes a sprite onto the sprite render queue */

View File

@ -69,7 +69,7 @@ void push_sprite(const t_push_sprite_args args) {
.texture_key = textures_get_key(&ctx.texture_cache, args.path), .texture_key = textures_get_key(&ctx.texture_cache, args.path),
.flip_x = m_or(args, flip_x, false), .flip_x = m_or(args, flip_x, false),
.flip_y = m_or(args, flip_y, false), .flip_y = m_or(args, flip_y, false),
.repeat = !m_or(args, scale, true), .repeat = !m_or(args, stretch, true),
m_opt_from(texture_origin, args, texture_origin) m_opt_from(texture_origin, args, texture_origin)
}; };
@ -211,6 +211,8 @@ static void render_sprites(const struct primitive_2d primitives[],
uv2 = (t_fvec2){ xr + wr * !sprite.flip_x, yr + hr * !sprite.flip_y }; uv2 = (t_fvec2){ xr + wr * !sprite.flip_x, yr + hr * !sprite.flip_y };
uv3 = (t_fvec2){ xr + wr * !sprite.flip_x, yr + hr * sprite.flip_y }; uv3 = (t_fvec2){ xr + wr * !sprite.flip_x, yr + hr * sprite.flip_y };
/* TODO: texture_origin support */
} else { } else {
/* try fitting texture into supplied destination rectangle */ /* try fitting texture into supplied destination rectangle */