Commit Graph

7 Commits

Author SHA1 Message Date
Felix Zedén Yverås
e4e22dee20 fix: rewrite coordinate management
After some initial smaller fixes, it turned out that I had broken
the red line used when linking fields. Fixing this was not trivial
as I found myself battling a lot of small bugs relating to scale
and translation in the existing code. This was made extra difficult
as a lot of coordinates were calculated when necessary in
Canvas.jsx.

This commit attempts to simplify the coordinate management in a few
different ways:
* There are now two distinct coordinate systems in use, typically
  referred to as "spaces". Screen space and diagram space.
* Diagram space is no longer measured in pixels (though the
  dimension-less measure used instead still maps to pixels at 100%
  zoom).
* The canvas now exposes helper methods for transforming between
  spaces.
* Zoom and translation is now managed via the svg viewBox property.
  * This makes moving items in diagram space much easier as the
    coordinates remain constant regardless of zoom level.
* The canvas now wraps the current mouse position in a context
  object, making mouse movement much easier to work with.
* The transform.pan property now refers to the center of the screen.

A new feature in this commit is that scroll wheel zoom is now based
on the current cursor location, making the diagram more convenient
to move around in.

I have tried to focus on Canvas.jsx and avoid changes that might be
desctructive on existing save files. I also believe more refactors
and abstractions could be introduced based on these changes to make
the diagram even easier to work with. However, I deem that out of
scope for now.
2024-07-17 22:22:52 +02:00
lilit
0371606829
Merge branch 'main' into i18n 2024-05-16 07:01:55 +03:00
1ilit
2b4b01c358 Configure i18n and add simplified chinese (#99) 2024-05-16 06:45:47 +03:00
liao文禧
a33b68bfd0 place optional parameters of functions at the end(#104) 2024-05-14 11:22:13 +08:00
1ilit
3ec93f42c6 Make variable naming consistent 2024-03-15 16:37:22 +02:00
1ilit
697291fe66 Fix setSelectedElement in contexts 2024-03-14 00:27:09 +02:00
1ilit
9e32c49306 Abstract areas 2024-03-11 23:59:04 +02:00