From cfde830b98e235cd2b5a72dca68160c2c1ff3b68 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Thu, 14 May 2026 21:19:36 -0400 Subject: 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. --- teensy/teensy_renderer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'teensy/teensy_renderer.c') 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; -- cgit v1.3-2-g0d8e