waves/waves.rs
1use terminal_graphics_interactive::prelude::*;
2
3fn main() -> std::io::Result<()> {
4 // An ocean. The mouse makes a glow, and the waves roll on.
5 sketch_with(Palette::ocean(), |cell| {
6 let swell =
7 (cell.x * 0.08 + cell.t).sin() * 0.5 + (cell.x * 0.19 - cell.t * 1.3).sin() * 0.25;
8 let surface = cell.height / 2.0 + swell * 6.0;
9 let glow = (-(cell.dist_to_mouse() * 0.12)).exp();
10 ((surface - cell.y) * 0.25 + glow * 0.5).clamp(-1.0, 1.0)
11 })
12}