Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable panning around the canvas #5

Open
5 tasks
DivineDominion opened this issue Jan 15, 2017 · 0 comments
Open
5 tasks

enable panning around the canvas #5

DivineDominion opened this issue Jan 15, 2017 · 0 comments

Comments

@DivineDominion
Copy link
Contributor

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 Strokes and fetching them for a given NSRect partition of itself.

That's similar to drawing and scrolling tile maps in 2D games. Canvasis 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.

@DivineDominion DivineDominion added this to the Sensible Prototype milestone Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant