P5JS - Distribute five objects in the diagonal of the browser

I have to distribute 5 objects (triangles, squares, etc.) diagonally.

I can do it by coordinates, but I want them to be centered on any computer.

I have the Canvas like this:

createCanvas (windowWidth, windowHeight);

I think it's easy, but I do not know how to do it.

Thank you


  • The best thing you can do for questions like this is to get out a sheet of graph paper and draw out a bunch of examples until you find a pattern. Try drawing different window width and heights and then placing the items. What are there positions?

Sign In or Register to comment.