C example
LCDBitmap* b = playdate->graphics->newBitmap(100, 100, kColorClear);
playdate->graphics->pushContext(b);
playdate->graphics->fillRect(0, 0, 10, 10, kColorWhite);
playdate->graphics->pushContext(NULL);
playdate->graphics->fillRect(0, 10, 10, 10, kColorWhite);
playdate->graphics->popContext();
playdate->graphics->fillRect(0, 20, 10, 10, kColorWhite);
playdate->graphics->popContext();
playdate->graphics->drawBitmap(b, 50, 50, kBitmapUnflipped);
Lua example
local b = playdate.graphics.image.new(100, 100)
playdate.graphics.pushContext(b)
playdate.graphics.fillRect(0, 0, 10, 10)
playdate.graphics.pushContext(nil)
playdate.graphics.fillRect(0, 10, 10, 10)
playdate.graphics.popContext()
playdate.graphics.fillRect(0, 20, 10, 10)
playdate.graphics.popContext()
b:draw(50, 50)
Proposed change
In Lua, pushContext(nil)
still stay focused on the image if it was before (and it is intuitive behavior). In C you need to push bitmap again (less expected, but clearly DOCUMENTED behavior).
If target is NULL , the drawing functions will use the display framebuffer.
I am asking to remove the message below from the doc, it is wrong and misleading. Or make them equivalent.
Equivalent to
playdate.graphics.pushContext()
in the Lua API.
Equivalent to
playdate->graphics->pushContext()
in the C API.