`rotatedImage` throws out image inversion

Hello!

This is on SDK 2.0.0.
When rotating an image with rotatedImage it seems like color inversion is ignored. I tried with invertedImage as well as setInverted, and neither works.

import "CoreLibs/graphics"

local gfx<const> = playdate.graphics

gfx.pushContext()
gfx.setPattern({0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF, 0x77})
gfx.fillRect(0, 0, 400, 240)
gfx.popContext()

local underlyingImg = gfx.image.new(400, 240);
gfx.pushContext(underlyingImg);
gfx.clear(gfx.kColorClear);
gfx.setColor(gfx.kColorBlack);
gfx.fillCircleAtPoint(50, 50, 25);
gfx.popContext();
-- underlyingImg contains a black circle at 50,50

local finalImg = gfx.image.new(400, 240, gfx.kColorClear);
gfx.pushContext(finalImg);
-- 1
underlyingImg:invertedImage():draw(0, 0)
-- 2
underlyingImg:invertedImage():rotatedImage(0):draw(50, 50)
-- 3
local invertedUnderlyingImg = underlyingImg:invertedImage()
invertedUnderlyingImg:rotatedImage(0):draw(100, 100)
-- 4
local mutatedUnderlyingImg = underlyingImg
mutatedUnderlyingImg:setInverted(true)
mutatedUnderlyingImg:rotatedImage(0):draw(150, 150)
gfx.popContext();

finalImg:draw(0, 0)

playdate.update = function()
end

buggyuggy

Additionally, if I try to draw with underlyingImg:invertedImage():drawRotated(0, 0, 0) the image just doesn't seem to draw at all.

Thanks so much for your help!

1 Like

Thanks for reporting this, we will look into it!

1 Like

I can confirm, I ran into the same problem. When the image rotates back to inital angle, it is inverted once again but goes away once rotate angle changes from initial angle.

I made a very simple lua project here...crank to see the problem, hit A to invert the bgColor.

1 Like

a work around: gfx.setImageDrawMode(gfx.kDrawModeFillWhite)

+1 here. The issue shows up with an image that has just white (and transparent) content. My example was a clear image with a white text rendered into it becoming black after rotation. However, when I add a black background the image, it gets rotated without an issue. (A weird head-scratcher indeed, as I had the image rendered against a fully black background.)

I use the fillWhite workaround.