Skip to main content

waft_widgets/widgets/
scroll_simulation.rs

1//! Flutter counterpart: `widgets/scroll_simulation.dart`.
2
3use std::fmt::{self, Debug};
4
5use waft_embedder::clamp_double;
6use waft_physics::{
7    FrictionSimulation, ScrollSpringSimulation, Simulation, SpringDescription, Tolerance,
8};
9
10/// An implementation of scroll physics that matches iOS.
11///
12/// See also:
13///
14///  * [`ClampingScrollSimulation`], which implements Android scroll physics.
15pub struct BouncingScrollSimulation {
16    /// When [`x`](Simulation::x) falls below this value the simulation switches from an
17    /// internal friction model to a spring model which causes
18    /// [`x`](Simulation::x) to "spring" back to [`leading_extent`](Self::leading_extent).
19    pub leading_extent: f64,
20
21    /// When [`x`](Simulation::x) exceeds this value the simulation switches from an
22    /// internal friction model to a spring model which causes
23    /// [`x`](Simulation::x) to "spring" back to [`trailing_extent`](Self::trailing_extent).
24    pub trailing_extent: f64,
25
26    /// The spring used to return [`x`](Simulation::x) to either
27    /// [`leading_extent`](Self::leading_extent) or
28    /// [`trailing_extent`](Self::trailing_extent).
29    pub spring: SpringDescription,
30
31    friction_simulation: Option<FrictionSimulation>,
32    spring_simulation: Option<ScrollSpringSimulation>,
33    spring_time: f64,
34
35    /// How close to the actual end of the simulation a value at a particular
36    /// time must be before [`is_done`](Simulation::is_done) considers the
37    /// simulation to be "done".
38    pub tolerance: Tolerance,
39}
40
41impl BouncingScrollSimulation {
42    /// Creates a simulation group for scrolling on iOS, with the given
43    /// parameters.
44    ///
45    /// The position and velocity arguments must use the same units as will be
46    /// expected from the [`x`](Simulation::x) and [`dx`](Simulation::dx) methods
47    /// respectively (typically logical pixels and logical pixels per second
48    /// respectively).
49    ///
50    /// The leading and trailing extents must use the unit of length, the same
51    /// unit as used for the position argument and as expected from the
52    /// [`x`](Simulation::x) method (typically logical pixels).
53    ///
54    /// The units used with the provided [`SpringDescription`] must similarly be
55    /// consistent with the other arguments.
56    pub fn new(
57        position: f64,
58        velocity: f64,
59        leading_extent: f64,
60        trailing_extent: f64,
61        spring: SpringDescription,
62    ) -> BouncingScrollSimulation {
63        BouncingScrollSimulation::with_options(
64            position,
65            velocity,
66            leading_extent,
67            trailing_extent,
68            spring,
69            0.0,
70            Tolerance::DEFAULT_TOLERANCE,
71        )
72    }
73
74    /// Dart's `constantDeceleration` / `tolerance` named arguments.
75    pub fn with_options(
76        position: f64,
77        velocity: f64,
78        leading_extent: f64,
79        trailing_extent: f64,
80        spring: SpringDescription,
81        constant_deceleration: f64,
82        tolerance: Tolerance,
83    ) -> BouncingScrollSimulation {
84        debug_assert!(leading_extent <= trailing_extent);
85        let mut simulation = BouncingScrollSimulation {
86            leading_extent,
87            trailing_extent,
88            spring,
89            friction_simulation: None,
90            spring_simulation: None,
91            spring_time: 0.0,
92            tolerance,
93        };
94        if position < leading_extent {
95            simulation.spring_simulation =
96                Some(simulation.underscroll_simulation(position, velocity));
97            simulation.spring_time = f64::NEG_INFINITY;
98        } else if position > trailing_extent {
99            simulation.spring_simulation =
100                Some(simulation.overscroll_simulation(position, velocity));
101            simulation.spring_time = f64::NEG_INFINITY;
102        } else {
103            // Taken from UIScrollView.decelerationRate (.normal = 0.998)
104            // 0.998^1000 = ~0.135
105            let friction_simulation = FrictionSimulation::with_options(
106                0.135,
107                position,
108                velocity,
109                tolerance,
110                constant_deceleration,
111            );
112            let final_x = friction_simulation.final_x();
113            if velocity > 0.0 && final_x > trailing_extent {
114                simulation.spring_time = friction_simulation.time_at_x(trailing_extent);
115                simulation.spring_simulation = Some(
116                    simulation.overscroll_simulation(
117                        trailing_extent,
118                        friction_simulation
119                            .dx(simulation.spring_time)
120                            .min(BouncingScrollSimulation::MAX_SPRING_TRANSFER_VELOCITY),
121                    ),
122                );
123                debug_assert!(simulation.spring_time.is_finite());
124            } else if velocity < 0.0 && final_x < leading_extent {
125                simulation.spring_time = friction_simulation.time_at_x(leading_extent);
126                simulation.spring_simulation = Some(
127                    simulation.underscroll_simulation(
128                        leading_extent,
129                        friction_simulation
130                            .dx(simulation.spring_time)
131                            .min(BouncingScrollSimulation::MAX_SPRING_TRANSFER_VELOCITY),
132                    ),
133                );
134                debug_assert!(simulation.spring_time.is_finite());
135            } else {
136                simulation.spring_time = f64::INFINITY;
137            }
138            simulation.friction_simulation = Some(friction_simulation);
139        }
140        simulation
141    }
142
143    /// The maximum velocity that can be transferred from the inertia of a ballistic
144    /// scroll into overscroll.
145    pub const MAX_SPRING_TRANSFER_VELOCITY: f64 = 5000.0;
146
147    fn underscroll_simulation(&self, x: f64, dx: f64) -> ScrollSpringSimulation {
148        ScrollSpringSimulation::new(self.spring, x, self.leading_extent, dx, self.tolerance)
149    }
150
151    fn overscroll_simulation(&self, x: f64, dx: f64) -> ScrollSpringSimulation {
152        ScrollSpringSimulation::new(self.spring, x, self.trailing_extent, dx, self.tolerance)
153    }
154
155    /// Dart's `_simulation`, which also stores the time offset in `_timeOffset` for the
156    /// caller to subtract; that scratch field is this second return value.
157    fn simulation(&self, time: f64) -> (&dyn Simulation, f64) {
158        if time > self.spring_time {
159            let time_offset = if self.spring_time.is_finite() {
160                self.spring_time
161            } else {
162                0.0
163            };
164            let spring = self
165                .spring_simulation
166                .as_ref()
167                .expect("a spring time below infinity means a spring simulation was built");
168            (spring, time_offset)
169        } else {
170            let friction = self
171                .friction_simulation
172                .as_ref()
173                .expect("a finite spring time means the friction simulation was built");
174            (friction, 0.0)
175        }
176    }
177}
178
179impl Simulation for BouncingScrollSimulation {
180    fn x(&self, time: f64) -> f64 {
181        let (simulation, time_offset) = self.simulation(time);
182        simulation.x(time - time_offset)
183    }
184
185    fn dx(&self, time: f64) -> f64 {
186        let (simulation, time_offset) = self.simulation(time);
187        simulation.dx(time - time_offset)
188    }
189
190    fn is_done(&self, time: f64) -> bool {
191        let (simulation, time_offset) = self.simulation(time);
192        simulation.is_done(time - time_offset)
193    }
194
195    fn tolerance(&self) -> Tolerance {
196        self.tolerance
197    }
198
199    /// Dart's `_simulation` assigns this simulation's tolerance to whichever inner
200    /// simulation it hands back, on every query; the inner simulations are built with it
201    /// and it is pushed down here instead, which no caller can tell apart.
202    fn set_tolerance(&mut self, tolerance: Tolerance) {
203        self.tolerance = tolerance;
204        if let Some(friction) = &mut self.friction_simulation {
205            friction.set_tolerance(tolerance);
206        }
207        if let Some(spring) = &mut self.spring_simulation {
208            spring.set_tolerance(tolerance);
209        }
210    }
211}
212
213impl Debug for BouncingScrollSimulation {
214    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
215        write!(
216            f,
217            "BouncingScrollSimulation(leadingExtent: {:?}, trailingExtent: {:?})",
218            self.leading_extent, self.trailing_extent
219        )
220    }
221}
222
223/// An implementation of scroll physics that aligns with Android.
224///
225/// For any value of [`velocity`](Self::velocity), this travels the same total distance as
226/// the Android scroll physics.
227///
228/// This scroll physics has been adjusted relative to Android's in order to make
229/// it ballistic, meaning that the deceleration at any moment is a function only
230/// of the current velocity [`dx`](Simulation::dx) and does not depend on how long ago the
231/// simulation was started. (This is required by Flutter's scrolling protocol,
232/// where `ScrollActivityDelegate.goBallistic` may restart a scroll activity
233/// using only its current velocity and the scroll position's own state.)
234/// Compared to this scroll physics, Android's moves faster at the very
235/// beginning, then slower, and it ends at the same place but a little later.
236///
237/// Times are measured in seconds, and positions in logical pixels.
238///
239/// See also:
240///
241///  * [`BouncingScrollSimulation`], which implements iOS scroll physics.
242//
243// This class is based on OverScroller.java from Android:
244//   https://android.googlesource.com/platform/frameworks/base/+/android-13.0.0_r24/core/java/android/widget/OverScroller.java#738
245// and in particular class SplineOverScroller (at the end of the file), starting
246// at method "fling".  (A very similar algorithm is in Scroller.java in the same
247// directory, but OverScroller is what's used by RecyclerView.)
248//
249// In the Android implementation, times are in milliseconds, positions are in
250// physical pixels, but velocity is in physical pixels per whole second.
251//
252// The "See..." comments below refer to SplineOverScroller methods and values.
253#[derive(Debug)]
254pub struct ClampingScrollSimulation {
255    /// The position of the particle at the beginning of the simulation, in
256    /// logical pixels.
257    pub position: f64,
258
259    /// The velocity at which the particle is traveling at the beginning of the
260    /// simulation, in logical pixels per second.
261    pub velocity: f64,
262
263    /// The amount of friction the particle experiences as it travels.
264    ///
265    /// The more friction the particle experiences, the sooner it stops and the
266    /// less far it travels.
267    ///
268    /// The default value causes the particle to travel the same total distance
269    /// as in the Android scroll physics.
270    // See mFlingFriction.
271    pub friction: f64,
272
273    /// The total time the simulation will run, in seconds.
274    duration: f64,
275
276    /// The total, signed, distance the simulation will travel, in logical pixels.
277    distance: f64,
278
279    /// How close to the actual end of the simulation a value at a particular
280    /// time must be before [`is_done`](Simulation::is_done) considers the
281    /// simulation to be "done".
282    pub tolerance: Tolerance,
283}
284
285// See DECELERATION_RATE. A `static final` in Dart; `f64::ln` is not a `const fn`.
286fn k_deceleration_rate() -> f64 {
287    0.78_f64.ln() / 0.9_f64.ln()
288}
289
290// See INFLEXION.
291const K_INFLEXION: f64 = 0.35;
292
293// See mPhysicalCoeff.  This has a value of 0.84 times Earth gravity,
294// expressed in units of logical pixels per second^2.
295const PHYSICAL_COEFF: f64 = 9.80665 // g, in meters per second^2
296    * 39.37 // 1 meter / 1 inch
297    * 160.0 // 1 inch / 1 logical pixel
298    * 0.84; // "look and feel tuning"
299
300impl ClampingScrollSimulation {
301    /// Dart's default `friction`, which causes the particle to travel the same total
302    /// distance as in the Android scroll physics.
303    pub const DEFAULT_FRICTION: f64 = 0.015;
304
305    /// Creates a scroll physics simulation that aligns with Android scrolling.
306    pub fn new(position: f64, velocity: f64) -> ClampingScrollSimulation {
307        ClampingScrollSimulation::with_options(
308            position,
309            velocity,
310            ClampingScrollSimulation::DEFAULT_FRICTION,
311            Tolerance::DEFAULT_TOLERANCE,
312        )
313    }
314
315    /// Dart's `friction` / `tolerance` named arguments.
316    pub fn with_options(
317        position: f64,
318        velocity: f64,
319        friction: f64,
320        tolerance: Tolerance,
321    ) -> ClampingScrollSimulation {
322        let mut simulation = ClampingScrollSimulation {
323            position,
324            velocity,
325            friction,
326            duration: 0.0,
327            distance: 0.0,
328            tolerance,
329        };
330        simulation.duration = simulation.fling_duration();
331        simulation.distance = simulation.fling_distance();
332        simulation
333    }
334
335    // See getSplineFlingDuration().
336    fn fling_duration(&self) -> f64 {
337        // See getSplineDeceleration().  That function's value is
338        // (velocity.abs() / referenceVelocity).ln().
339        let reference_velocity = self.friction * PHYSICAL_COEFF / K_INFLEXION;
340
341        // This is the value getSplineFlingDuration() would return, but in seconds.
342        let android_duration =
343            (self.velocity.abs() / reference_velocity).powf(1.0 / (k_deceleration_rate() - 1.0));
344
345        // We finish a bit sooner than Android, in order to travel the
346        // same total distance.
347        k_deceleration_rate() * K_INFLEXION * android_duration
348    }
349
350    // See getSplineFlingDistance().  This returns the same value but with the
351    // sign of [`velocity`](Self::velocity), and in logical pixels.
352    fn fling_distance(&self) -> f64 {
353        let distance = self.velocity * self.duration / k_deceleration_rate();
354        if cfg!(debug_assertions) {
355            // This is the more complicated calculation that getSplineFlingDistance()
356            // actually performs, which boils down to the much simpler formula above.
357            let reference_velocity = self.friction * PHYSICAL_COEFF / K_INFLEXION;
358            let log_velocity = (self.velocity.abs() / reference_velocity).ln();
359            let distance_again = self.friction
360                * PHYSICAL_COEFF
361                * (log_velocity * k_deceleration_rate() / (k_deceleration_rate() - 1.0)).exp();
362            debug_assert!((distance.abs() - distance_again).abs() < self.tolerance.distance);
363        }
364        distance
365    }
366}
367
368impl Simulation for ClampingScrollSimulation {
369    fn x(&self, time: f64) -> f64 {
370        let t = clamp_double(time / self.duration, 0.0, 1.0);
371        self.position + self.distance * (1.0 - (1.0 - t).powf(k_deceleration_rate()))
372    }
373
374    fn dx(&self, time: f64) -> f64 {
375        let t = clamp_double(time / self.duration, 0.0, 1.0);
376        self.velocity * (1.0 - t).powf(k_deceleration_rate() - 1.0)
377    }
378
379    fn is_done(&self, time: f64) -> bool {
380        time >= self.duration
381    }
382
383    fn tolerance(&self) -> Tolerance {
384        self.tolerance
385    }
386
387    fn set_tolerance(&mut self, tolerance: Tolerance) {
388        self.tolerance = tolerance;
389    }
390}
391
392#[cfg(test)]
393mod tests {
394    use super::*;
395
396    fn default_spring() -> SpringDescription {
397        SpringDescription::with_damping_ratio_value(0.5, 100.0, 1.1)
398    }
399
400    /// Runs the simulation to its end at 60Hz and returns the time it stopped at.
401    fn run_to_completion(simulation: &dyn Simulation, deadline: f64) -> f64 {
402        let mut time = 0.0;
403        while !simulation.is_done(time) {
404            time += 1.0 / 60.0;
405            assert!(
406                time < deadline,
407                "the simulation must finish before {deadline}s"
408            );
409        }
410        time
411    }
412
413    /// `scroll_simulation_test.dart`: "ClampingScrollSimulation has a stable initial
414    /// conditions".
415    #[test]
416    fn clamping_scroll_simulation_has_stable_initial_conditions() {
417        for (position, velocity) in [
418            (51.0, 2866.91537),
419            (584.0, 2617.294734),
420            (0.0, 1831.366634),
421            (-156.2, 1541.57665),
422            (5469.0, 182.114534),
423        ] {
424            let simulation = ClampingScrollSimulation::new(position, velocity);
425            assert!((simulation.x(0.0) - position).abs() < 1e-9);
426            assert!((simulation.dx(0.0) - velocity).abs() < 1e-9);
427        }
428    }
429
430    /// `scroll_simulation_test.dart`: "ClampingScrollSimulation only decelerates, never
431    /// speeds up".
432    #[test]
433    fn clamping_scroll_simulation_only_decelerates() {
434        let simulation = ClampingScrollSimulation::new(0.0, 8000.0);
435        let mut time = 0.0;
436        let mut velocity = simulation.dx(time);
437        while !simulation.is_done(time) {
438            assert!(time < 3.0);
439            time += 1.0 / 60.0;
440            let next_velocity = simulation.dx(time);
441            assert!(next_velocity <= velocity);
442            velocity = next_velocity;
443        }
444        assert!(velocity.abs() < 1e-9);
445    }
446
447    /// The fling duration and distance Android's `SplineOverScroller` produces for a
448    /// 8000 logical-pixel-per-second fling.
449    #[test]
450    fn clamping_scroll_simulation_travels_its_fling_distance_over_its_fling_duration() {
451        let simulation = ClampingScrollSimulation::new(0.0, 8000.0);
452        assert!(!simulation.is_done(2.1183617));
453        assert!(simulation.is_done(2.118361712));
454        assert!((simulation.x(2.2) - 7186.362753988744).abs() < 1e-6);
455        assert_eq!(simulation.dx(2.2), 0.0);
456    }
457
458    /// A fling that stays inside the extents runs the friction model to a stop.
459    #[test]
460    fn bouncing_scroll_simulation_uses_friction_inside_the_extents() {
461        let simulation =
462            BouncingScrollSimulation::new(0.0, 200.0, -1000.0, 1000.0, default_spring());
463        assert_eq!(simulation.x(0.0), 0.0);
464        assert_eq!(simulation.dx(0.0), 200.0);
465        let time = run_to_completion(&simulation, 10.0);
466        let resting = simulation.x(time);
467        assert!(resting > 0.0 && resting < 1000.0, "stopped at {resting}");
468    }
469
470    /// A position past the leading extent starts on the spring and settles on the extent.
471    #[test]
472    fn bouncing_scroll_simulation_springs_back_to_the_leading_extent() {
473        let simulation = BouncingScrollSimulation::new(-100.0, 0.0, 0.0, 500.0, default_spring());
474        assert_eq!(simulation.x(0.0), -100.0);
475        let time = run_to_completion(&simulation, 10.0);
476        assert!(
477            simulation.x(time).abs() < 0.1,
478            "settled at {}",
479            simulation.x(time)
480        );
481    }
482
483    /// A fling fast enough to leave the trailing extent hands off to the spring, which
484    /// brings it back to that extent.
485    /// A list released past its end while moving back into it is the spring's alone, as Flutter's
486    /// is: however fast the release, the list comes to rest with its end at the viewport's, rather
487    /// than decelerating on into the content. The release is one recorded on an iPhone: 377 px, the
488    /// end at 303, moving back at 7,276 px/s.
489    #[test]
490    fn bouncing_scroll_simulation_springs_a_release_moving_back_from_past_the_end_to_the_end() {
491        let simulation =
492            BouncingScrollSimulation::new(377.0, -7276.0, 0.0, 303.0, default_spring());
493        let stopped = run_to_completion(&simulation, 5.0);
494        assert!(
495            (simulation.x(stopped) - 303.0).abs() < 0.01,
496            "{}",
497            simulation.x(stopped)
498        );
499    }
500
501    #[test]
502    fn bouncing_scroll_simulation_hands_a_fast_fling_to_the_trailing_spring() {
503        let simulation = BouncingScrollSimulation::new(0.0, 5000.0, 0.0, 100.0, default_spring());
504        // The friction phase alone would carry the particle far past the extent.
505        assert!(simulation.x(0.1) > 100.0);
506        let time = run_to_completion(&simulation, 10.0);
507        assert!(
508            (simulation.x(time) - 100.0).abs() < 0.1,
509            "settled at {}",
510            simulation.x(time)
511        );
512    }
513
514    /// `physics/newton_test.dart`: "test_kinetic_scroll".
515    #[test]
516    fn bouncing_scroll_simulation_switches_from_friction_to_the_spring() {
517        let spring = SpringDescription::with_damping_ratio_value(1.0, 50.0, 0.5);
518
519        let mut scroll = BouncingScrollSimulation::new(100.0, 800.0, 0.0, 300.0, spring);
520        scroll.set_tolerance(Tolerance {
521            velocity: 0.5,
522            distance: 0.1,
523            ..Tolerance::DEFAULT_TOLERANCE
524        });
525        assert!(!scroll.is_done(0.0));
526        assert!(!scroll.is_done(0.5)); // switch from friction to spring
527        assert!(scroll.is_done(3.5));
528
529        let mut scroll2 = BouncingScrollSimulation::new(100.0, -800.0, 0.0, 300.0, spring);
530        scroll2.set_tolerance(Tolerance {
531            velocity: 0.5,
532            distance: 0.1,
533            ..Tolerance::DEFAULT_TOLERANCE
534        });
535        assert!(!scroll2.is_done(0.0));
536        assert!(!scroll2.is_done(0.5)); // switch from friction to spring
537        assert!(scroll2.is_done(3.5));
538    }
539
540    /// `physics/newton_test.dart`: "scroll_with_inf_edge_ends".
541    #[test]
542    fn bouncing_scroll_simulation_stays_on_friction_with_an_infinite_trailing_extent() {
543        let spring = SpringDescription::with_damping_ratio_value(1.0, 50.0, 0.5);
544        let mut scroll = BouncingScrollSimulation::new(100.0, 400.0, 0.0, f64::INFINITY, spring);
545        scroll.set_tolerance(Tolerance {
546            velocity: 1.0,
547            ..Tolerance::DEFAULT_TOLERANCE
548        });
549
550        assert!(!scroll.is_done(0.0));
551        assert_eq!(scroll.x(0.0), 100.0);
552        assert_eq!(scroll.dx(0.0), 400.0);
553
554        assert!((scroll.x(1.0) - 272.0).abs() < 1.0);
555        assert!((scroll.dx(1.0) - 54.0).abs() < 1.0);
556        assert!((scroll.dx(2.0) - 7.0).abs() < 1.0);
557        assert!(scroll.dx(3.0) < 1.0);
558
559        assert!(scroll.is_done(5.0));
560        assert!((scroll.x(5.0) - 300.0).abs() < 1.0);
561    }
562
563    /// `physics/newton_test.dart`: "over/under scroll spring".
564    #[test]
565    fn bouncing_scroll_simulation_overscrolls_then_springs_back() {
566        let spring = SpringDescription::with_damping_ratio_value(1.0, 170.0, 1.1);
567        let mut scroll = BouncingScrollSimulation::new(500.0, -7500.0, 0.0, 1000.0, spring);
568        scroll.set_tolerance(Tolerance {
569            velocity: 45.0,
570            distance: 1.5,
571            ..Tolerance::DEFAULT_TOLERANCE
572        });
573
574        assert!(!scroll.is_done(0.0));
575        assert!((scroll.x(0.0) - 500.0).abs() < 1e-9);
576        assert!((scroll.dx(0.0) + 7500.0).abs() < 1e-9);
577
578        // Expect to reach 0.0 at about t=.07 at which point the simulation will
579        // switch from friction to the spring
580        assert!(!scroll.is_done(0.065));
581        assert!((scroll.x(0.065) - 42.0).abs() < 1.0);
582        assert!((scroll.dx(0.065) + 6584.0).abs() < 1.0);
583
584        // We've overscrolled (0.1 > 0.07). Trigger the underscroll
585        // simulation, and reverse direction
586        assert!(!scroll.is_done(0.1));
587        assert!((scroll.x(0.1) + 123.0).abs() < 1.0);
588        assert!((scroll.dx(0.1) + 2613.0).abs() < 1.0);
589
590        // Headed back towards 0.0 and slowing down.
591        assert!(!scroll.is_done(0.5));
592        assert!((scroll.x(0.5) + 15.0).abs() < 1.0);
593        assert!((scroll.dx(0.5) - 124.0).abs() < 1.0);
594
595        // Now jump back to the beginning, because we can.
596        assert!(!scroll.is_done(0.0));
597        assert!((scroll.x(0.0) - 500.0).abs() < 1e-9);
598        assert!((scroll.dx(0.0) + 7500.0).abs() < 1e-9);
599
600        assert!(scroll.is_done(2.0));
601        assert_eq!(scroll.x(2.0), 0.0);
602        assert!(scroll.dx(2.0).abs() < 1.0);
603    }
604
605    #[test]
606    fn bouncing_scroll_simulation_to_string_names_its_extents() {
607        let simulation = BouncingScrollSimulation::new(0.0, 0.0, -1.0, 500.0, default_spring());
608        assert_eq!(
609            format!("{simulation:?}"),
610            "BouncingScrollSimulation(leadingExtent: -1.0, trailingExtent: 500.0)"
611        );
612    }
613}