Coordinate systems in Playdate SDK

I am reading through the SDK and found the function setClipRect that takes a rectangle position and size in world coordinates. Then I found the same function but for screen coordinates (setScreenClipRect). This led me to try to find a place where these coordinates systems were explained but I couldn't find it. I haven't started going into the tutorials so maybe this is more obvious later but I think maybe this should be explained in the SDK documentation too.

Is there a place where this is explained. My guess is that screen space is 0,0 at the top left with pixel coordinates going to 400 Ă— 240 pixels at the bottom right. Then world coordinates are the same but normalized i.e. 0,0 at the top left and 1,1 at the bottom right.

Is this correct?

Is the drawing offset the only thing that can affect the world coordinate system? Or am I missing something else?

Is screen space also affected by drawing offset? My guess is that it is not but it is worth checking.

1 Like

I found the Graphics conventions section which answered part of my questions but I am hoping someone can help me clarify the rest.

“World” coordinates could be drawn on different parts of the screen depending on the draw offset you set in playdate.graphics.setDrawOffset(). “Screen” coordinates refer to screen pixels but I think can still be transformed via the functions in playdate.display (.setScale, etc).

For example, if you call playdate.graphics.setDrawOffset(20, 20) then 5,5 in world coordinates would be at 25,25 on the actual screen (screen coordinates).

So AFAIK:

  • World coordinates are affected by both the playdate.graphics draw offset and the playdate.display settings (flip, scale, offset, etc)
  • screen coordinates are only affected by the playdate.display settings
1 Like