CleanCocoa / CleanCocoa/InfiniteCanvas

enable panning around the canvas

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
144
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I think this is rather simple.

- [ ] Holding the spacebar changes the tool from drawing to panning until you release the key.
- [ ] Decouple `CanvasView` coordinate system from a `Canvas` coordinate system:
- [ ] When you pan, you add the drag/mouse-move vector `(Δx, Δy)` to a `scrollOffset`. Maybe part of the `CanvasView` itself, because it's a presentation detail.
- [ ] A `Canvas` representation then takes care of holding on to `Stroke`s and fetching them for a given `NSRect` partition of itself.

That's similar to drawing and scrolling tile maps in 2D games. `Canvas`is the map, `CanvasView` is the viewport or camera that moves around and asks the map for everything that's inside its boundary.

- [ ] Similarly, new strokes have to be translated from the `CanvasView` coordinates to the `Canvas` coordinate system.

Essentially, you just add the `scrollOffset: (Δx, Δy)` to the view coordinates and that should do the trick.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.