0

I grew up with computer graphics in the 1980s, thinking in Cartesian coordinates, with the origin in the bottom left, and the vertical y axis increasing as you go "up" the screen. But nearly every modern graphics system uses the same coordinate systems for pixels as is done for characters on a terminal, with the origin in the top left, and vertical axis increasing as you go "down". It's counter-intuitive to me that a higher number is lower on the screen.

Also, I'd like to specify the position of shapes and so on using world coordinates independent of the canvas' current dimensions in pixels. For instance I could say my canvas is 640 x 480 coordinates in size, and position 320,440 should always be in the center of the canvas.

Is there a way that I can set up p5.js to use my way of thinking?

I tried using translate() and scale() in the setup function, but this seems to have no effect. I later saw Changing the coordinate system in P5.js which is close, but I also want to scale for world coordinates.

mike
  • 1,854
  • 17
  • 23
  • Does this answer your question? [Changing the coordinate system in P5.js](https://stackoverflow.com/questions/60325768/changing-the-coordinate-system-in-p5-js). If not, please share your attempt as a [mcve] so we can diagnose the issue. Thanks. – ggorlen May 20 '23 at 00:22
  • It's close. I wanted to [ask/answer](https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions/) for reference later. – mike May 20 '23 at 00:27
  • 1
    I would answer in the existing thread as a canonical rather than opening a new question. Otherwise, information is spread thinly and it becomes difficult for future visitors to piece all of the existing knowledge together. When you do ask and answer, all of the normal requirements for asking still apply, like the MCVE. – ggorlen May 20 '23 at 00:28
  • added [an answer](https://stackoverflow.com/a/76293099/776953). I was feeling that a separate, more specific question/answer might be better than another answer going on a tangent, but I do see your point. – mike May 20 '23 at 00:40
  • Not a huge deal either way, thanks for the contribution! Your post will probably get more exposure in the other thread. – ggorlen May 20 '23 at 00:41

0 Answers0