diff options
| author | iamcheeseman <[email protected]> | 2026-05-14 21:19:36 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-14 21:19:36 -0400 |
| commit | cfde830b98e235cd2b5a72dca68160c2c1ff3b68 (patch) | |
| tree | 881f73cfde766d1b5cd510aa3e54b9ccc2aafff9 /teensy | |
| parent | 0baf1793f7ebd778a7b63a956d58767b4e3dfe94 (diff) | |
fix image clipping on the left and top of screen
Previously, texture coordinates would not be correctly calculated
because the clamped draw positions were used to decide texture
coordinates, instead of the intended draw position.
Diffstat (limited to 'teensy')
| -rw-r--r-- | teensy/teensy_renderer.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/teensy/teensy_renderer.c b/teensy/teensy_renderer.c index db9193f..1df1f1b 100644 --- a/teensy/teensy_renderer.c +++ b/teensy/teensy_renderer.c @@ -158,7 +158,7 @@ void ty_draw_image(ty_Image img, ty_Vec2i pos) for (int dx = p1.x; dx < p2.x; dx++) { ty_Color px = ty_img_get_pixel( img, - ty_vec2i(dx - p1.x, dy - p1.y) + ty_vec2i(dx - pos.x, dy - pos.y) ); if (memcmp(&px, &BLEND_COLOR, sizeof(px)) == 0) continue; @@ -181,8 +181,8 @@ void ty_draw_image_ex( for (int dy = p1.y; dy < p2.y; dy++) { for (int dx = p1.x; dx < p2.x; dx++) { - int img_x = ((dx - p1.x) * src.w) / dst.w + src.x; - int img_y = ((dy - p1.y) * src.h) / dst.h + src.y; + int img_x = ((dx - dst.x) * src.w) / dst.w + src.x; + int img_y = ((dy - dst.y) * src.h) / dst.h + src.y; ty_Color px = ty_img_get_pixel(img, ty_vec2i(img_x, img_y)); if (memcmp(&px, &BLEND_COLOR, sizeof(px)) == 0) continue; |
