shithub: libgraphics

Download patch

ref: 5cc40b1dea29dfc40831f69c3f1a8f72a47b5d18
parent: 216f83db15a2c6f28794e4be25165f5ac55270ef
author: rodri <rgl@antares-labs.eu>
date: Mon Sep 9 17:32:21 EDT 2024

texture: clamp the coordinates instead of aborting when out of bounds.

--- a/texture.c
+++ b/texture.c
@@ -24,7 +24,8 @@
 static Point
 uv2tp(Point2 uv, Texture *t)
 {
-	assert(uv.x >= 0 && uv.x <= 1 && uv.y >= 0 && uv.y <= 1);
+	uv.x = fclamp(uv.x, 0, 1);
+	uv.y = fclamp(uv.y, 0, 1);
 	return Pt(uv.x*Dx(t->image->r), (1 - uv.y)*Dy(t->image->r));
 }