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.
Add a pub zoom: f64 field to the DrawingState struct
Set the default zoom to 1.0 in the Default implementation of DrawingState
Add methods to Drawing that perform the appropriate queries to get and set the zoom
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
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
.pub zoom: f64
field to theDrawingState
struct1.0
in theDefault
implementation ofDrawingState
Drawing
that perform the appropriate queries to get and set the zoomDrawing
, not elsewhere)Next, we need to implement zoom in the renderer:
ConvertScreenCoordinates
extension trait methods and then doing the calculation thereTasks
Anyone can attempt to do one or more of these tasks. I am happy to help.
Drawing
Renderer