{
"id": "161",
"prompt": "EASING library in 0..16 fixed-point, published for spawn_lib consumers: ease_in(n16) quadratic, ease_out(n16) inverted square, ease_io(n16) split halves, and tween(a, b, n16, mode) selecting the curve (0 linear, 1 in, 2 out, 3 in-out - exactly 4 params, the compose::call limit). Make the landing frame() animate four blocks racing left-right off a triangle wave of t so all four curves are visibly different.",
"solution_rl": "fn ease_in(n16: i32) -> i32 {\n n16 * n16 / 16\n}\n\nfn ease_out(n16: i32) -> i32 {\n 16 - (16 - n16) * (16 - n16) / 16\n}\n\nfn ease_io(n16: i32) -> i32 {\n if n16 < 8 {\n ease_in(n16 * 2) / 2\n } else {\n 8 + ease_out((n16 - 8) * 2) / 2\n }\n}\n\nfn tween(a: i32, b: i32, n16: i32, mode: i32) -> i32 {\n let mut e: i32 = n16;\n if mode == 1 { e = ease_in(n16); }\n if mode == 2 { e = ease_out(n16); }\n if mode == 3 { e = ease_io(n16); }\n a + (b - a) * e / 16\n}\n\nfn dims() -> i32 {\n (256 << 16) | 152\n}\n\nfn frame(t: i32) {\n host::display::clear(0x000000);\n host::display::draw_string(8, 8, \"LIB EASE\", 0xffffff, 2);\n host::display::draw_string(8, 30, \"IN OUT IO TWEEN\", 0x00ff66, 1);\n let mut n: i32 = t % 64;\n if n > 32 { n = 64 - n; }\n let n16: i32 = n / 2;\n host::display::fill_rect(tween(8, 224, n16, 0), 56, 24, 16, 0x808080);\n host::display::fill_rect(tween(8, 224, n16, 1), 78, 24, 16, 0xff8040);\n host::display::fill_rect(tween(8, 224, n16, 2), 100, 24, 16, 0x40c0ff);\n host::display::fill_rect(tween(8, 224, n16, 3), 122, 24, 16, 0x40ff80);\n host::display::present();\n}\n",
"tags": [
"library",
"functions",
"animation"
]
}