I want to calculate the pixels that need to be on in the range. What I do is when I parse the data to the function I get the position of 2 points/pixels. I wan to calculate the pixels in between to turn on. I’m not sure where to start. Any ideas?
(I hope I understood your question correctly. Correct me if I didn’t). The solution to this problem is similar to how one would calculate the minimum and maximum vector3 when using Region3 which works by finding the minimum and maximum of all axis between both vectors. This is a function that returns a table containing the “pixels” in between 2 “pixels”:
local min = math.min
local max = math.max
function getBetween(x1,y1, x2,y2)
local returnT = {}
--Getting the minimum and maximum of both coordinates
local minX = min(x1,x2)
local minY = min(y1,y2)
local maxX = max(x1,x2)
local maxY = max(y1,y2)
--Looping through the range
for y = minY, maxY do
for x = minX, maxX do
if(x ~= x1 or y ~= y1) and (x ~= x2 or y ~= y2) then --Making sure the original values wont be included (disable this statement if you want the original coordinates to be included)
table.insert(returnT, {
Column = x,
Row = y
})
end
end
end
return returnT
end