Issue scaling the size of a display window

I'm trying to get a program window to scale properly.

I designed the program to fit a screen with a 3:2 aspect ratio, so I set the size to 1020,680 while building it, with the intention of using size(displayWidth, displayHeight) when finished.

Of course, that would simply run the program at a size of 1020,680 with blank spaces beyond that.

So in all of my X-locations I use the simple equation "width/(1020/X)", and in all my Y-locations use "height/(680/Y)"

I've used this method to make program windows scale to different sizes before, but never on a program as complicated as this one, and sure enough it didn't work this time. So I wrote a very simple program to figure out where the issue is and then started adding layers of complexity until eventually got to this point:
(Note: it didn't get very complex before I ran into a problem)

``````PImage bubble;

void setup(){
size(1020,680);
print(width + "    ");
println( height);
}

void draw(){
background(0);
noFill();
stroke(255);
imageMode(CORNER);
ellipse( 150,100,50,50);
stroke(0,0,255);
ellipse( width/(1020/150),height/(680/100),50,50);
}
``````

which resulted in this:

width = 1020.... height = 680...

so.... width/(1020/150) = 1020/(1020/150) = 150

and.... height/(680/100) = 680/(680/100) = 100

so why-oh-why are those two circles not in the same location?

Apologies!!!!!
I just realized I posted a processing question to the wrong forum!
I instinctively come here when I hit a roadblock,
Sorry!!!!!!! :o

Jrodenba:
So in all of my X-locations I use the simple equation "width/(1020/X)", and in all my Y-locations use "height/(680/Y)"

width/(1020/X) = (width / 1020) * X = X

Why don't you use map?

``````Xcoord = map(X, XMin, XMax, 0, width);
``````

Why don't you use map?

Well... I guess I could, but I've got around 5000 X and Y locations, seems like the map function would be rather memory intensive, I don't know that the method I'm using would conserve memory any more than the map function though.

But I'm still not sure why those two circles aren't in the same location.
It's not the exact problem I was working on, but it's going to bug me if I can't figure it out

Is there an option to delete my post? I feel bad for posting to the wrong forum.

No need to delete posts, If there is a need for sorting the moderators will do that.
A posts referred to in answers should not be deleted anyway.

The different positions are probably due to rounding errors of integer operations involved.

Try to make at least on of the operands a float and the position will be the same.

``````ellipse( width/(1020.0/150),height/(680.0/100),50,50);
``````