lucaspevidor / InteractiveCanvas

A training project for interacting with an environment through HTML canvas
GNU General Public License v3.0
1 stars 0 forks source link

Feature/zoom on center #25

Closed lucaspevidor closed 1 year ago

lucaspevidor commented 1 year ago

Canvas normal scaling operation

When scaling the canvas using ctx.scale() method, it scales around the origin (0, 0). This is counter intuitive for my canvas application, and having it scale around the center of the canvas is much more pleasing, and a better experience overall.

Fix

After scaling the canvas, a translation is applied to it, to counteract the movement caused by the pivot being off-center.

Issues introduced

While examining the code, an inconsistency was identified between the canvas position and the Rigidbodies positions, causing major issues with the zoom fix. The issue was corrected, but some parameters have to be fine-tuned to limit the canvas movement, in order to not break the application.

This pull request closes #20