Potentials – Respect the Ratio

Building Great Code

Today I noticed that the display code for Potentials was filling the display viewport - and distorting the shapes in the simulation. For example, a "square" could be made to look like a long rectangle, simply by resizing the window. This wasn't right. So today I spent a little time to fix this.

The code wasn't that hard, and to save a little time, I computed the drawing "origin" as well as the scale factor for the drawing to the NSView so that each part of the drawing didn't have to recompute these. Nothing fancy - just scale to the one dimension that will fit in the viewport, and then fix that, adjust everything else.

Potentials where the Ratio is Right

At this point, you can see the added white "letter boxing" on the window as we have respected the ratio of the workspace, and the drawing is being constrained in the vertical dimension. Simple, but very nice.

Little by little, it's getting better. 🙂