I read a lot, and tried many things, but can't get this done, and it seems simple
I have the following p5js code
function setup() {
let canvas = createCanvas(400, 400);
noLoop();
}
function draw() {
background(220);
push();
translate(50,100);
point(25,25);
// MISSING CODE to get 75,125
pop();
}
And I'm trying to figure out if there is a way to get the actual coordinates were the point is drawn, I read about getTransform, the matrix, and a lot of stuff, but seems impossible to get it done. Also I need to use rotation in the transform, so that makes it even harder
Thanks!
Use variables, so you can keep track of how much you translated and the location of your point, so you can them add them to obtain the desired result.
You could use Vectors so you don't have to define 2 variables, but you get the idea.
Usually you would call WorldPosition to the absolute position of the object and RelativePosition to the position the object relative to the CameraPosition
The translation would be called CameraPosition and to make your code more efficient you should only draw objects that their RelativePosition falls inside the drawable area.