From 8878f095fb711c253783731c1e2ed99e0d872561 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 8 Jan 2022 09:12:03 -0600 Subject: [PATCH] Basically only imortant from #408 Leave blackSqare and step counters alone, but make it be able to handle textures where width and height are not the same so no more invalid color error. For example, with original code, materials.newDebugTexture(8, 16, 40) has odd color because when it gets to pixel (1, 9), color value is (15, 9, -2) in RGB. After color.RGBToInteger inside color.HSBToInteger, integer value for color would be -2. The reason it's not apparent is likely from optimization of colors from palette, turning -2 into 65535 or (0, 255, 255), instead of an invalid color. This has the effect of screwing up the colors for the image If steps are swapped as this proposes, this issue is fixed and the colors wouldn't go crazy. --- Libraries/OpenComputersGL/Materials.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/OpenComputersGL/Materials.lua b/Libraries/OpenComputersGL/Materials.lua index 5b22c2d2..d498814d 100755 --- a/Libraries/OpenComputersGL/Materials.lua +++ b/Libraries/OpenComputersGL/Materials.lua @@ -12,8 +12,8 @@ materials.types = { function materials.newDebugTexture(width, height, h) local texture = {width = width, height = height} - local bStep = 1 / height - local sStep = 1 / width + local bStep = 1 / width + local sStep = 1 / height local s, b = 0, 0 local blackSquare = false