Graphics context "offsets" should be relative to those of the prior context

  • Call pd->graphics->pushContext(NULL) to push a new context onto the stack
  • If I call pd->graphics->setDrawOffset(100, 100) then all of my draw calls will have their origin set to (100, 100). Cool. This is what I expect.
  • Again call pushContext(NULL), followed by setDrawOffset(20, 20)

I would expect my draw calls to have their origin at (120, 120) because I never popped the first context. I would expect my current context to be "offset" relative to the prior context. Unfortunately however, the origin is now (20, 20).

I'm not sure whether this is a bug or a an intended feature, but it's quite unintuitive given that contexts are structured as a stack.

If this is by design, perhaps new calls with different semantics would make sense. Something like "setOffset" and "setAbsoluteOffset" to enable both relative and absolute offsets.

I think you have a couple of misunderstandings. setDrawOffset() sets the draw offset relative to the origin, not relative to the previous offset. Also, graphics contexts are way of saving and restoring state — not a way to turn absolute coordinates into relative ones. (You may be thinking of nested coordinate systems.)

If you want to set a new draw offset relative to the old one, you can do that with a little extra code:

local offsetX, offsetY = + 20, offsetY + 20)
1 Like