From a1584e019472dd1813741ec4a832ba5c1899f031 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Tue, 29 Dec 2020 08:04:25 -0800 Subject: [PATCH] Don't use DrawRect to clear an image, a pixel loop is an order of magnitude faster. --- src/textures.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/textures.c b/src/textures.c index 8b9d38cdb..cc5755214 100644 --- a/src/textures.c +++ b/src/textures.c @@ -2348,7 +2348,8 @@ Rectangle GetImageAlphaBorder(Image image, float threshold) // Clear image background with given color void ImageClearBackground(Image *dst, Color color) { - ImageDrawRectangle(dst, 0, 0, dst->width, dst->height, color); + for (int i = 0; i < dst->width * dst->height; ++i) + ImageDrawPixel(dst, i % dst->width, i / dst->height, color); } // Draw pixel within an image