Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the screen coordinates of origin after a bunch of transforms P5.js

I'm trying to track the position of an object so I can draw a trail behind it in p5.js.

I'm moving the object around the screen with the translate() and rotate() functions, and in order to draw a trail I was going to store the object's position after each update in an array. I'm aware there was something like what I'm asking for in processing 3, the model X, Y and Z functions, but as far as I can tell these haven't been implemented in the javascript version yet.

Even accessing the canvas's current transform matrix is proving problematic, and at this point I'm considering a redesign to omit the transform part of the api until this functionality is added.

So my question basically is: is there any way to determine the screen(canvas) coordinates of (0, 0) after applying a bunch of transforms?

like image 925
Aaron Greig Avatar asked Oct 30 '22 04:10

Aaron Greig


1 Answers

I have a solution for this problem here:

https://github.com/ChristerNilsson/Transformer

like image 88
Kri-ban Avatar answered Nov 14 '22 03:11

Kri-ban