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

Zoom #46

Open
3 tasks
sunjay opened this issue Dec 20, 2017 · 0 comments
Open
3 tasks

Zoom #46

sunjay opened this issue Dec 20, 2017 · 0 comments

Comments

@sunjay
Copy link
Owner

sunjay commented Dec 20, 2017

We probably need a better renderer (#45) before we do this, but it would be great if zoom was settable on Drawing and also manipulatable through the keyboard/mouse (#42) and the toolbar (#41).

The first step to making all of that possible is making zoom a gettable and settable property in Drawing.

  1. Add a pub zoom: f64 field to the DrawingState struct
  2. Set the default zoom to 1.0 in the Default implementation of DrawingState
  3. Add methods to Drawing that perform the appropriate queries to get and set the zoom
  4. For the time-being, valid zoom values will be from 0.2 to 5.0 (arbitrary choices) and any values outside of this range should panic with a helpful error message (check this value in the methods of Drawing, not elsewhere)
    • We can always extend this range later but trying to make the range smaller is quite difficult because it would be a breaking change

Next, we need to implement zoom in the renderer:

  • Zoom is relative to the center
  • A point (1.0, 1.0) at 1.0 zoom is (2.5, 2.5) at 2.5 zoom.
  • The easiest and most foolproof way of implementing this is probably by adding a zoom parameter to the ConvertScreenCoordinates extension trait methods and then doing the calculation there

Tasks

Anyone can attempt to do one or more of these tasks. I am happy to help.

  • Add zoom to Drawing
  • Add zoom to Renderer
  • Add examples that thoroughly test the range of zooms
    • e.g. Example where turtle is moving and while the turtle moves the zoom is set to values throughout the range of valid zoms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant