
paintutils.drawImage incorrectly modifies terminal background color
WorldChallenge1 opened this issue ยท 1 comments
Minecraft Version
1.20.1
Version
1.133.0 (Fabric)
Details
Description
The paintutils.drawImage()
function incorrectly modifies the terminal's background color when drawing an image, even when the image should not affect the background color outside of the drawn area.
Expected Behavior
After calling paintutils.drawImage()
, the terminal's background color should remain unchanged from what was set before the function call. The function should only modify pixels within the bounds of the drawn image.
Actual Behavior
The terminal's background color is changed after calling paintutils.drawImage()
, affecting the entire terminal's background color setting.
Steps to Reproduce
- Set a specific background color using
term.setBackgroundColor()
- Clear the terminal and note the current background color
- Parse an image using
paintutils.parseImage()
- Draw the image using
paintutils.drawImage()
- Check the background color after drawing - it will have changed
Reproduction Code
-- Bug reproduction for paintutils.drawImage changing background color
term.setBackgroundColor(colors.cyan)
term.clear()
term.setCursorPos(1, 1)
current_color = term.getBackgroundColour()
print("Current color: " .. tostring(current_color))
local sprite = [[
55
5555
5555
55 ]]
local image = paintutils.parseImage(sprite)
paintutils.drawImage(image, 10, 5) -- Bug occurs here
color_after = term.getBackgroundColour()
print("Color after drawing image: " .. tostring(color_after))
if current_color == color_after then
print("Background color unchanged after drawing image.")
else
print("Background color changed after drawing image!")
end
For anyone else facing this bug, as a workaround in the mean time you can store the current color with term.getBackgroundColour()
before drawing the image and then setting it after drawing the image with term.setBackgroundColour()
Example:
-- Bug reproduction for paintutils.drawImage changing background color
term.setBackgroundColor(colors.cyan)
term.clear()
term.setCursorPos(1, 1)
current_color = term.getBackgroundColour()
print("Current color: " .. tostring(current_color))
local sprite = [[
55
5555
5555
55 ]]
local image = paintutils.parseImage(sprite)
paintutils.drawImage(image, 10, 5) -- Bug occurs here
term.setBackgroundColor(current_color) -- add this line
color_after = term.getBackgroundColour()
print("Color after drawing image: " .. tostring(color_after))
if current_color == color_after then
print("Background color unchanged after drawing image.")
else
print("Background color changed after drawing image!")
end