pax-std 0.39.1

Standard library for Pax, including layouts, drawing primitives, and form controls
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
#![allow(unused_imports)]

use crate::*;
use pax_engine::api::*;
use pax_engine::*;

const MID_X: f64 = 50.0768;
const TOP_BACK_LEFT: Point = Point::new(MID_X, 0.0);
const TOP_BACK_RIGHT: Point = Point::new(100.0, 5.2404);
const TOP_FRONT_LEFT: Point = Point::new(0.0, 5.622);
const TOP_FRONT_RIGHT: Point = Point::new(MID_X, 10.4807);
const BOTTOM_LEFT: Point = Point::new(0.0, 93.3227);
const BOTTOM_RIGHT: Point = Point::new(MID_X, 100.0);
const BACKING_BOTTOM_RIGHT: Point = Point::new(100.0, 94.7597);

// The source artwork occupies 96% of the logo's presentation height.
const CANVAS_Y_SCALE: f64 = 0.96;
const COMPONENT_WIDTH_PX: f64 = 137.23;
const COMPONENT_HEIGHT_PX: f64 = 463.95;
const X_PX_PER_PERCENT: f64 = COMPONENT_WIDTH_PX / 100.0;
const Y_PX_PER_PERCENT: f64 = COMPONENT_HEIGHT_PX * CANVAS_Y_SCALE / 100.0;

const INITIAL_ROLL_RADIUS_PX: f64 = 13.0;

/// The rolling fabric post used by [`AnimatedPaxLogo`].
#[pax]
#[engine_import_path("pax_engine")]
#[custom(Default)]
#[file("drawing/pax_logo/animated_pax_logo_post.pax")]
pub struct AnimatedPaxLogoPost {
    pub fill: Property<Paint>,
    pub backing_fill: Property<Paint>,
    pub progress: Property<f64>,
    pub rolling: Property<f64>,
    pub extension: Property<f64>,
    pub wave: Property<f64>,
    pub swing: Property<f64>,
    pub fall: Property<f64>,
    pub roll_radius_px: Property<f64>,
    pub top_fabric_elements: Property<Vec<PathElement>>,
    pub fabric_elements: Property<Vec<PathElement>>,
    pub backing_fabric_elements: Property<Vec<PathElement>>,
    pub roll_start_cap_elements: Property<Vec<PathElement>>,
    pub roll_body_elements: Property<Vec<PathElement>>,
    pub roll_end_cap_elements: Property<Vec<PathElement>>,
}

impl Default for AnimatedPaxLogoPost {
    fn default() -> Self {
        let motion = motion_from_controls(MotionControls::default());
        Self {
            fill: Property::new(Paint::Solid(Color::BLACK)),
            backing_fill: Property::new(Paint::Solid(Color::WHITE)),
            progress: Property::new(0.0),
            rolling: Property::new(0.0),
            extension: Property::new(0.0),
            wave: Property::new(0.0),
            swing: Property::new(0.0),
            fall: Property::new(0.0),
            roll_radius_px: Property::new(INITIAL_ROLL_RADIUS_PX),
            top_fabric_elements: Property::new(top_fabric_path(motion)),
            fabric_elements: Property::new(fabric_path(motion)),
            backing_fabric_elements: Property::new(backing_fabric_path(0.0)),
            roll_start_cap_elements: Property::new(roll_start_cap_path(motion)),
            roll_body_elements: Property::new(roll_body_path(motion)),
            roll_end_cap_elements: Property::new(roll_end_cap_path(motion)),
        }
    }
}

impl AnimatedPaxLogoPost {
    pub fn handle_mount(&mut self, _ctx: &NodeContext) {
        let rolling = self.rolling.local();
        let extension = self.extension.local();
        let wave = self.wave.local();
        let swing = self.swing.local();
        let fall = self.fall.local();
        let roll_radius_px = self.roll_radius_px.local();
        let motion_dependencies = [
            rolling.untyped(),
            extension.untyped(),
            wave.untyped(),
            swing.untyped(),
            fall.untyped(),
            roll_radius_px.untyped(),
        ];
        let motion = LocalProperty::computed(
            move || {
                motion_from_controls(MotionControls {
                    rolling: rolling.get(),
                    extension: extension.get(),
                    wave: wave.get(),
                    swing: swing.get(),
                    fall: fall.get(),
                    roll_radius_px: roll_radius_px.get(),
                })
            },
            &motion_dependencies,
        );

        self.top_fabric_elements
            .replace_with(computed_path(&motion, top_fabric_path));
        self.fabric_elements
            .replace_with(computed_path(&motion, fabric_path));
        let extension = self.extension.local();
        self.backing_fabric_elements
            .replace_with(LocalProperty::computed(
                move || backing_fabric_path(extension.get()),
                &[self.extension.untyped()],
            ));
        self.roll_start_cap_elements
            .replace_with(computed_path(&motion, roll_start_cap_path));
        self.roll_body_elements
            .replace_with(computed_path(&motion, roll_body_path));
        self.roll_end_cap_elements
            .replace_with(computed_path(&motion, roll_end_cap_path));
    }
}

fn computed_path(
    motion: &LocalProperty<PostMotion>,
    build: fn(PostMotion) -> Vec<PathElement>,
) -> LocalProperty<Vec<PathElement>> {
    let motion = motion.clone();
    let dependencies = [motion.untyped()];
    LocalProperty::computed(move || build(motion.get()), &dependencies)
}

pub(crate) fn settled_post_paths() -> [Vec<PathElement>; 6] {
    let motion = motion_from_controls(MotionControls {
        rolling: 1.0,
        extension: 1.0,
        wave: 0.0,
        swing: 0.0,
        fall: 1.0,
        roll_radius_px: 0.7,
    });
    [
        roll_start_cap_path(motion),
        roll_body_path(motion),
        roll_end_cap_path(motion),
        top_fabric_path(motion),
        fabric_path(motion),
        backing_fabric_path(1.0),
    ]
}

#[derive(Clone, Copy, Debug, Default, PartialEq)]
struct Point {
    x: f64,
    y: f64,
}

impl Point {
    const fn new(x: f64, y: f64) -> Self {
        Self { x, y }
    }

    fn lerp(self, other: Self, t: f64) -> Self {
        Self::new(lerp(self.x, other.x, t), lerp(self.y, other.y, t))
    }

    fn add(self, other: Self) -> Self {
        Self::new(self.x + other.x, self.y + other.y)
    }

    fn scale(self, amount: f64) -> Self {
        Self::new(self.x * amount, self.y * amount)
    }
}

#[derive(Clone, Copy)]
struct MotionControls {
    rolling: f64,
    extension: f64,
    wave: f64,
    swing: f64,
    fall: f64,
    roll_radius_px: f64,
}

impl Default for MotionControls {
    fn default() -> Self {
        Self {
            rolling: 0.0,
            extension: 0.0,
            wave: 0.0,
            swing: 0.0,
            fall: 0.0,
            roll_radius_px: INITIAL_ROLL_RADIUS_PX,
        }
    }
}

#[derive(Clone, Copy, Default)]
struct PostMotion {
    rolling: f64,
    wave: f64,
    swing: f64,
    fall: f64,
    fabric_bottom_left: Point,
    fabric_bottom_right: Point,
    roll_axis_start: Point,
    roll_axis_end: Point,
    roll_radius_px: f64,
}

impl Interpolatable for PostMotion {}

fn motion_from_controls(controls: MotionControls) -> PostMotion {
    let base_bottom_left = Point::new(
        lerp(TOP_FRONT_LEFT.x, BOTTOM_LEFT.x, controls.extension)
            + controls.swing
            + controls.wave * 0.12,
        lerp(TOP_FRONT_LEFT.y, BOTTOM_LEFT.y, controls.extension),
    );
    let base_bottom_right = Point::new(
        lerp(TOP_FRONT_RIGHT.x, BOTTOM_RIGHT.x, controls.extension)
            + controls.swing * 0.75
            + controls.wave * 0.55,
        lerp(TOP_FRONT_RIGHT.y, BOTTOM_RIGHT.y, controls.extension),
    );
    let (roll_axis_start, roll_axis_end) = if controls.fall <= f64::EPSILON {
        (
            TOP_BACK_LEFT.lerp(TOP_FRONT_LEFT, controls.rolling),
            TOP_BACK_RIGHT.lerp(TOP_FRONT_RIGHT, controls.rolling),
        )
    } else {
        (base_bottom_left, base_bottom_right)
    };

    PostMotion {
        rolling: controls.rolling,
        wave: controls.wave,
        swing: controls.swing,
        fall: controls.fall,
        fabric_bottom_left: base_bottom_left,
        fabric_bottom_right: base_bottom_right,
        roll_axis_start,
        roll_axis_end,
        roll_radius_px: controls.roll_radius_px,
    }
}

fn top_fabric_path(motion: PostMotion) -> Vec<PathElement> {
    let reveal = motion.rolling.max(0.002);
    let moving_left = TOP_BACK_LEFT.lerp(TOP_FRONT_LEFT, reveal);
    let moving_right = TOP_BACK_RIGHT.lerp(TOP_FRONT_RIGHT, reveal);

    vec![
        point_element(TOP_BACK_LEFT),
        PathElement::Line,
        point_element(TOP_BACK_RIGHT),
        PathElement::Line,
        point_element(moving_right),
        PathElement::Line,
        point_element(moving_left),
        PathElement::Close,
    ]
}

fn fabric_path(motion: PostMotion) -> Vec<PathElement> {
    let bottom_left = motion.fabric_bottom_left;
    let bottom_right = motion.fabric_bottom_right;
    let left_extent = bottom_left.y - TOP_FRONT_LEFT.y;
    let right_extent = bottom_right.y - TOP_FRONT_RIGHT.y;
    let roll_sag =
        radius_y_percent(motion.roll_radius_px) * motion.fall * (1.0 - motion.fall) * 0.65;
    let left_upper = Point::new(
        motion.swing * 0.05 - motion.wave * 0.08,
        TOP_FRONT_LEFT.y + left_extent / 3.0,
    );
    let left_middle = Point::new(
        motion.swing * 0.52 + motion.wave * 0.32,
        TOP_FRONT_LEFT.y + left_extent * 2.0 / 3.0,
    );
    let right_upper = Point::new(
        TOP_FRONT_RIGHT.x - motion.wave * 0.22,
        TOP_FRONT_RIGHT.y + right_extent / 3.0,
    );
    let right_middle = Point::new(
        TOP_FRONT_RIGHT.x + motion.swing * 0.70 + motion.wave * 0.90,
        TOP_FRONT_RIGHT.y + right_extent * 2.0 / 3.0,
    );
    let left_edge = [TOP_FRONT_LEFT, left_upper, left_middle, bottom_left];
    let right_edge = [bottom_right, right_middle, right_upper, TOP_FRONT_RIGHT];

    let mut path = vec![point_element(TOP_FRONT_LEFT)];
    append_catmull_rom_edge(&mut path, &left_edge);
    path.extend([
        PathElement::Cubic(
            percent_x(lerp(bottom_left.x, bottom_right.x, 1.0 / 3.0)),
            percent_y(lerp(bottom_left.y, bottom_right.y, 1.0 / 3.0) + roll_sag),
            percent_x(lerp(bottom_left.x, bottom_right.x, 2.0 / 3.0)),
            percent_y(lerp(bottom_left.y, bottom_right.y, 2.0 / 3.0) + roll_sag),
        ),
        point_element(bottom_right),
    ]);
    append_catmull_rom_edge(&mut path, &right_edge);
    path.push(PathElement::Close);
    path
}

fn backing_fabric_path(extension: f64) -> Vec<PathElement> {
    let extension = extension.clamp(0.0, 1.018).max(0.002);
    let bottom_left = TOP_FRONT_RIGHT.lerp(BOTTOM_RIGHT, extension);
    let bottom_right = TOP_BACK_RIGHT.lerp(BACKING_BOTTOM_RIGHT, extension);

    vec![
        point_element(TOP_FRONT_RIGHT),
        PathElement::Line,
        point_element(TOP_BACK_RIGHT),
        PathElement::Line,
        point_element(bottom_right),
        PathElement::Line,
        point_element(bottom_left),
        PathElement::Close,
    ]
}

fn append_catmull_rom_edge(path: &mut Vec<PathElement>, points: &[Point; 4]) {
    for index in 0..3 {
        let previous = if index == 0 {
            points[index]
        } else {
            points[index - 1]
        };
        let start = points[index];
        let end = points[index + 1];
        let next = if index == 2 {
            points[index + 1]
        } else {
            points[index + 2]
        };
        let control_1 = Point::new(
            start.x + (end.x - previous.x) / 6.0,
            start.y + (end.y - previous.y) / 6.0,
        );
        let control_2 = Point::new(
            end.x - (next.x - start.x) / 6.0,
            end.y - (next.y - start.y) / 6.0,
        );
        path.push(PathElement::Cubic(
            percent_x(control_1.x),
            percent_y(control_1.y),
            percent_x(control_2.x),
            percent_y(control_2.y),
        ));
        path.push(point_element(end));
    }
}

fn roll_start_cap_path(motion: PostMotion) -> Vec<PathElement> {
    circle_path(motion.roll_axis_start, motion.roll_radius_px)
}

fn roll_end_cap_path(motion: PostMotion) -> Vec<PathElement> {
    circle_path(motion.roll_axis_end, motion.roll_radius_px)
}

fn roll_body_path(motion: PostMotion) -> Vec<PathElement> {
    let start = motion.roll_axis_start;
    let end = motion.roll_axis_end;
    let normal = normal_offset(start, end, motion.roll_radius_px);

    vec![
        point_element(start.add(normal)),
        PathElement::Line,
        point_element(end.add(normal)),
        PathElement::Line,
        point_element(end.add(normal.scale(-1.0))),
        PathElement::Line,
        point_element(start.add(normal.scale(-1.0))),
        PathElement::Close,
    ]
}

fn circle_path(center: Point, radius_px: f64) -> Vec<PathElement> {
    let rx = radius_x_percent(radius_px);
    let ry = radius_y_percent(radius_px);
    let kappa = 0.552_284_749_830_793_6;
    vec![
        point_element(Point::new(center.x + rx, center.y)),
        PathElement::Cubic(
            percent_x(center.x + rx),
            percent_y(center.y + ry * kappa),
            percent_x(center.x + rx * kappa),
            percent_y(center.y + ry),
        ),
        point_element(Point::new(center.x, center.y + ry)),
        PathElement::Cubic(
            percent_x(center.x - rx * kappa),
            percent_y(center.y + ry),
            percent_x(center.x - rx),
            percent_y(center.y + ry * kappa),
        ),
        point_element(Point::new(center.x - rx, center.y)),
        PathElement::Cubic(
            percent_x(center.x - rx),
            percent_y(center.y - ry * kappa),
            percent_x(center.x - rx * kappa),
            percent_y(center.y - ry),
        ),
        point_element(Point::new(center.x, center.y - ry)),
        PathElement::Cubic(
            percent_x(center.x + rx * kappa),
            percent_y(center.y - ry),
            percent_x(center.x + rx),
            percent_y(center.y - ry * kappa),
        ),
        point_element(Point::new(center.x + rx, center.y)),
        PathElement::Close,
    ]
}

fn normal_offset(start: Point, end: Point, radius_px: f64) -> Point {
    let dx_px = (end.x - start.x) * X_PX_PER_PERCENT;
    let dy_px = (end.y - start.y) * Y_PX_PER_PERCENT;
    let length_px = (dx_px * dx_px + dy_px * dy_px).sqrt().max(f64::EPSILON);
    Point::new(
        (-dy_px / length_px * radius_px) / X_PX_PER_PERCENT,
        (dx_px / length_px * radius_px) / Y_PX_PER_PERCENT,
    )
}

#[cfg(test)]
fn screen_distance(start: Point, end: Point) -> f64 {
    let dx = (end.x - start.x) * X_PX_PER_PERCENT;
    let dy = (end.y - start.y) * Y_PX_PER_PERCENT;
    (dx * dx + dy * dy).sqrt()
}

fn radius_x_percent(radius_px: f64) -> f64 {
    radius_px / X_PX_PER_PERCENT
}

fn radius_y_percent(radius_px: f64) -> f64 {
    radius_px / Y_PX_PER_PERCENT
}

fn point_element(point: Point) -> PathElement {
    PathElement::Point(percent_x(point.x), percent_y(point.y))
}

fn percent_x(value: f64) -> Size {
    percent(value)
}

fn percent(value: f64) -> Size {
    Size::Percent(Numeric::F64(value))
}

fn percent_y(value: f64) -> Size {
    percent(value * CANVAS_Y_SCALE)
}

fn lerp(start: f64, end: f64, t: f64) -> f64 {
    start + (end - start) * t
}

#[cfg(test)]
mod tests {
    use super::*;

    fn top_controls(rolling: f64, radius: f64) -> MotionControls {
        MotionControls {
            rolling,
            roll_radius_px: radius,
            ..Default::default()
        }
    }

    fn fall_controls(
        extension: f64,
        fall: f64,
        wave: f64,
        swing: f64,
        radius: f64,
    ) -> MotionControls {
        MotionControls {
            rolling: 1.0,
            extension,
            fall,
            wave,
            swing,
            roll_radius_px: radius,
        }
    }

    #[test]
    fn post_paths_keep_stable_topologies_at_every_motion_phase() {
        let samples = [
            top_controls(0.0, INITIAL_ROLL_RADIUS_PX),
            top_controls(0.5, 8.125),
            top_controls(1.0, 6.5),
            fall_controls(0.25, 0.5, -5.2503, -7.0, 3.6),
            fall_controls(1.0, 1.0, 0.0, 0.0, 0.7),
            fall_controls(1.018, 1.0, 0.0, 0.0, 0.7),
        ];

        for controls in samples {
            let motion = motion_from_controls(controls);
            let top = top_fabric_path(motion);
            let fabric = fabric_path(motion);
            let start_cap = roll_start_cap_path(motion);
            let body = roll_body_path(motion);
            let end_cap = roll_end_cap_path(motion);
            assert_eq!(top.len(), 8);
            assert_eq!(top.last(), Some(&PathElement::Close));
            assert_eq!(fabric.len(), 16);
            assert_eq!(fabric.last(), Some(&PathElement::Close));
            assert_eq!(start_cap.len(), 10);
            assert_eq!(start_cap.last(), Some(&PathElement::Close));
            assert_eq!(body.len(), 8);
            assert_eq!(body.last(), Some(&PathElement::Close));
            assert_eq!(end_cap.len(), 10);
            assert_eq!(end_cap.last(), Some(&PathElement::Close));
            assert_eq!(backing_fabric_path(controls.extension).len(), 8);
        }
    }

    #[test]
    fn white_post_face_drops_as_a_rigid_parallelogram() {
        let settled = backing_fabric_path(1.0);
        assert_eq!(settled[0], point_element(TOP_FRONT_RIGHT));
        assert_eq!(settled[2], point_element(TOP_BACK_RIGHT));
        assert_eq!(settled[4], point_element(BACKING_BOTTOM_RIGHT));
        assert_eq!(settled[6], point_element(BOTTOM_RIGHT));
    }

    #[test]
    fn top_face_is_revealed_before_the_descent() {
        let start = motion_from_controls(top_controls(0.0, INITIAL_ROLL_RADIUS_PX));
        let rolled = motion_from_controls(top_controls(1.0, 6.5));
        let falling = motion_from_controls(fall_controls(0.25, 0.5, 0.0, 0.0, 3.6));

        assert_eq!(start.fabric_bottom_left, TOP_FRONT_LEFT);
        assert_eq!(rolled.rolling, 1.0);
        assert_eq!(rolled.fabric_bottom_left, TOP_FRONT_LEFT);
        assert!(falling.fabric_bottom_left.y > TOP_FRONT_LEFT.y);
    }

    #[test]
    fn collapsed_fabric_has_no_pre_fall_sag() {
        let collapsed = fabric_path(motion_from_controls(top_controls(
            1.0,
            INITIAL_ROLL_RADIUS_PX,
        )));
        let straight_bottom_edge = PathElement::Cubic(
            percent_x(lerp(TOP_FRONT_LEFT.x, TOP_FRONT_RIGHT.x, 1.0 / 3.0)),
            percent_y(lerp(TOP_FRONT_LEFT.y, TOP_FRONT_RIGHT.y, 1.0 / 3.0)),
            percent_x(lerp(TOP_FRONT_LEFT.x, TOP_FRONT_RIGHT.x, 2.0 / 3.0)),
            percent_y(lerp(TOP_FRONT_LEFT.y, TOP_FRONT_RIGHT.y, 2.0 / 3.0)),
        );

        assert_eq!(collapsed[7], straight_bottom_edge);

        let falling = fabric_path(motion_from_controls(fall_controls(0.5, 0.5, 0.0, 0.0, 3.6)));
        assert_ne!(falling[7], straight_bottom_edge);
    }

    #[test]
    fn capsule_keeps_its_axis_spanning_the_prism_edge() {
        let expected = screen_distance(TOP_BACK_LEFT, TOP_BACK_RIGHT);
        for rolling in [0.0, 0.25, 0.5, 0.75, 1.0] {
            let motion = motion_from_controls(top_controls(rolling, 10.0));
            let length = screen_distance(motion.roll_axis_start, motion.roll_axis_end);
            assert!((length - expected).abs() < 0.5);
        }
    }

    #[test]
    fn settled_post_matches_the_original_rigid_extents() {
        let motion = motion_from_controls(fall_controls(1.0, 1.0, 0.0, 0.0, 0.7));
        let path = fabric_path(motion);
        assert_eq!(path[6], point_element(BOTTOM_LEFT));
        assert_eq!(path[8], point_element(BOTTOM_RIGHT));
    }

    #[test]
    fn scalar_controls_drive_spool_shrink_and_full_extension() {
        let start = motion_from_controls(top_controls(0.0, INITIAL_ROLL_RADIUS_PX));
        let settled = motion_from_controls(fall_controls(1.0, 1.0, 0.0, 0.0, 0.7));

        assert_eq!(start.roll_radius_px, INITIAL_ROLL_RADIUS_PX);
        assert!(start.roll_radius_px > settled.roll_radius_px);
        assert_eq!(settled.fabric_bottom_left, BOTTOM_LEFT);
        assert_eq!(settled.fabric_bottom_right, BOTTOM_RIGHT);
    }

    #[test]
    fn lower_edge_extends_past_the_wall_then_returns() {
        let peak = motion_from_controls(fall_controls(1.018, 1.0, 0.0, 0.0, 0.7));
        let settled = motion_from_controls(fall_controls(1.0, 1.0, 0.0, 0.0, 0.7));

        assert!(peak.fabric_bottom_left.y > BOTTOM_LEFT.y);
        assert!(peak.fabric_bottom_right.y > BOTTOM_RIGHT.y);
        assert_eq!(settled.fabric_bottom_left, BOTTOM_LEFT);
        assert_eq!(settled.fabric_bottom_right, BOTTOM_RIGHT);
    }

    #[test]
    fn spool_geometry_intentionally_overflows_the_post_bounds() {
        assert!(TOP_BACK_LEFT.y - radius_y_percent(INITIAL_ROLL_RADIUS_PX) < 0.0);
        assert!(TOP_FRONT_LEFT.x - radius_x_percent(INITIAL_ROLL_RADIUS_PX) < 0.0);
    }
}