@@ -178,7 +178,7 @@ mod grid {
178
178
fn default ( ) -> Self {
179
179
Self {
180
180
life : Life :: default ( ) ,
181
- interaction : Interaction :: default ( ) ,
181
+ interaction : Interaction :: None ,
182
182
cache : Cache :: default ( ) ,
183
183
translation : Vector :: default ( ) ,
184
184
scaling : 1.0 ,
@@ -187,6 +187,9 @@ mod grid {
187
187
}
188
188
189
189
impl Grid {
190
+ const MIN_SCALING : f32 = 0.1 ;
191
+ const MAX_SCALING : f32 = 2.0 ;
192
+
190
193
pub fn tick ( & mut self ) {
191
194
self . life . tick ( ) ;
192
195
self . cache . clear ( )
@@ -286,10 +289,12 @@ mod grid {
286
289
mouse:: Event :: WheelScrolled { delta } => match delta {
287
290
mouse:: ScrollDelta :: Lines { y, .. }
288
291
| mouse:: ScrollDelta :: Pixels { y, .. } => {
289
- if y > 0.0 && self . scaling < 2.0
290
- || y < 0.0 && self . scaling > 0.25
292
+ if y < 0.0 && self . scaling > Self :: MIN_SCALING
293
+ || y > 0.0 && self . scaling < Self :: MAX_SCALING
291
294
{
292
- self . scaling += y / 30.0 ;
295
+ self . scaling = ( self . scaling + y / 30.0 )
296
+ . max ( Self :: MIN_SCALING )
297
+ . min ( Self :: MAX_SCALING ) ;
293
298
294
299
self . cache . clear ( ) ;
295
300
}
@@ -467,10 +472,4 @@ mod grid {
467
472
Drawing ,
468
473
Panning { translation : Vector , start : Point } ,
469
474
}
470
-
471
- impl Default for Interaction {
472
- fn default ( ) -> Interaction {
473
- Interaction :: None
474
- }
475
- }
476
475
}
0 commit comments