diff --git a/Cargo.lock b/Cargo.lock index 68f9341..89b5ea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,13 +169,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" -[[package]] -name = "circle" -version = "0.1.0" -dependencies = [ - "nannou", -] - [[package]] name = "clipboard-win" version = "2.2.0" @@ -2302,6 +2295,13 @@ dependencies = [ "smithay-client-toolkit 0.6.6", ] +[[package]] +name = "spircles" +version = "0.1.0" +dependencies = [ + "nannou", +] + [[package]] name = "spirv_cross" version = "0.23.1" diff --git a/crates/spircles/Cargo.toml b/crates/spircles/Cargo.toml new file mode 100644 index 0000000..cdc62de --- /dev/null +++ b/crates/spircles/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "spircles" +version = "0.1.0" +edition = "2018" + +[dependencies] +nannou = "0.17" diff --git a/crates/spircles/src/main.rs b/crates/spircles/src/main.rs new file mode 100644 index 0000000..2e94572 --- /dev/null +++ b/crates/spircles/src/main.rs @@ -0,0 +1,83 @@ +use nannou::prelude::*; + +fn main() { + nannou::app(model).update(update).simple_window(view).run(); +} + +struct Model {} + +fn model(_app: &App) -> Model { + Model {} +} + +fn update(_app: &App, _model: &mut Model, _update: Update) {} + +const fn color(red: u8, green: u8, blue: u8) -> Rgb { + Rgb { + red, + green, + blue, + standard: std::marker::PhantomData::, + } +} + +const BG: Rgb = color(0, 5, 5); +const BALL: Rgb = color(255, 255, 255); + +const COLORS: &[Rgb] = &[ + color(125, 22, 22), + color(107, 19, 16), + color(69, 15, 16), + color(72, 0, 50), + color(223, 0, 84), + color(255, 139, 106), + color(255, 214, 194), +]; + +const fn sm_color(i: i32, j: i32) -> Rgb { + if i == 0 && j == 0 { + BG + } else { + BALL + } +} +const fn bg_color(i: i32, j: i32) -> Rgb { + if i == 0 && j == 0 { + return BALL; + } + + let x = i * i * i * j + j * j + 3 + i + j + i * j; + COLORS[x.abs() as usize % COLORS.len()] +} + +fn view(app: &App, _model: &Model, frame: Frame) { + let draw = app.draw(); + + draw.background().color(BG); + + for i in -4..=4 { + for j in -4..=4 { + let speed = map_range((i + j).abs() as f32, 0.0, 8.0, 0.1, 2.0); + let dis = (app.time * speed).sin() * 10.0; + + let circ_offset = vec2( + (app.time + (i * i) as f32).sin() * dis, + (app.time + (j * i) as f32).cos() * dis, + ); + + let x = i as f32 * 100.0 * (app.time * 0.7).sin(); + let y = j as f32 * 100.0 * (app.time * 0.7).cos(); + + draw.ellipse() + .w_h(40.0, 40.0) + .x_y(x + circ_offset.x, y + circ_offset.y) + .color(bg_color(i, j)); + draw.ellipse() + .w_h(10.0, 10.0) + .x_y(x, y) + .color(sm_color(i, j)); + } + } + + draw.to_frame(app, &frame).unwrap(); +}