mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Fixes invalid buffer indexing in rawSemiPixelRectangle() method
This commit is contained in:
parent
4d9ca1d0f2
commit
bc50f9c31a
@ -434,20 +434,32 @@ local function semiPixelSet(x, y, color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function drawSemiPixelRectangle(x, y, width, height, color)
|
local function drawSemiPixelRectangle(x, y, width, height, color)
|
||||||
local index, indexStepForward, indexStepBackward, jPercentTwoEqualsZero, jFixed = bufferWidth * (mathCeil(y / 2) - 1) + x, (bufferWidth - width), width
|
local index, evenYIndexStep, oddYIndexStep, realY, evenY =
|
||||||
for j = y, y + height - 1 do
|
bufferWidth * (mathCeil(y / 2) - 1) + x,
|
||||||
jPercentTwoEqualsZero = j % 2 == 0
|
(bufferWidth - width),
|
||||||
|
width
|
||||||
|
|
||||||
for i = x, x + width - 1 do
|
for pseudoY = y, y + height - 1 do
|
||||||
jFixed = mathCeil(j / 2)
|
realY = mathCeil(pseudoY / 2)
|
||||||
semiPixelRawSet(index, color, jPercentTwoEqualsZero)
|
|
||||||
index = index + 1
|
if realY >= drawLimitY1 and realY <= drawLimitY2 then
|
||||||
|
evenY = pseudoY % 2 == 0
|
||||||
|
|
||||||
|
for pseudoX = x, x + width - 1 do
|
||||||
|
if pseudoX >= drawLimitX1 and pseudoX <= drawLimitX2 then
|
||||||
|
semiPixelRawSet(index, color, evenY)
|
||||||
end
|
end
|
||||||
|
|
||||||
if jPercentTwoEqualsZero then
|
index = index + 1
|
||||||
index = index + indexStepForward
|
end
|
||||||
else
|
else
|
||||||
index = index - indexStepBackward
|
index = index + width
|
||||||
|
end
|
||||||
|
|
||||||
|
if evenY then
|
||||||
|
index = index + evenYIndexStep
|
||||||
|
else
|
||||||
|
index = index - oddYIndexStep
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user