How to center the alignment always

Hi, I was learning processing and I was trying something with the co ordinates, and I am having trouble in aligning to the center of the display window, for reference I have attached the video.

In detailed explanation or example there are two circles starting to slide across X & Y axis,
so when the animation is triggered they will move across the screen and cross exactly at the center of the display window no matter of the ratio of the width and the height, like 500x500 or 500x700 or 700x500.

is there any idea that I can get.

1 Like

do you use a

translate( width/2,height/2);

in draw ( beginning)?

then your math must be PLUS / MINUS rel. to NULL

Hi there Hermanth, welcome to the forum. Have you tried coding something yet which you want to share? That way we have something to work from.

To make sure something is at the middle of the screen, divide the width or height by two :slight_smile:

Yeah, width and height are inbuilt variables and you can calculate the center with



You can also call ellipseMode(CENTER); prior using ellipse