main
annieversary 2021-10-25 20:32:07 +01:00
parent 9e706fa8c9
commit 9906e3f611
6 changed files with 161 additions and 10 deletions

67
Cargo.lock generated
View File

@ -236,7 +236,7 @@ dependencies = [
"daggy 0.5.0",
"fnv",
"instant",
"num",
"num 0.3.1",
"pistoncore-input",
"rusttype 0.8.3",
]
@ -1075,7 +1075,7 @@ dependencies = [
"gif",
"jpeg-decoder",
"num-iter",
"num-rational",
"num-rational 0.3.2",
"num-traits",
"png",
"scoped_threadpool",
@ -1587,11 +1587,25 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f"
dependencies = [
"num-bigint",
"num-complex",
"num-bigint 0.3.2",
"num-complex 0.3.1",
"num-integer",
"num-iter",
"num-rational",
"num-rational 0.3.2",
"num-traits",
]
[[package]]
name = "num"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
dependencies = [
"num-bigint 0.4.2",
"num-complex 0.4.0",
"num-integer",
"num-iter",
"num-rational 0.4.0",
"num-traits",
]
@ -1606,6 +1620,17 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.3.1"
@ -1615,6 +1640,15 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
dependencies = [
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.44"
@ -1643,7 +1677,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
"autocfg",
"num-bigint",
"num-bigint 0.3.2",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
dependencies = [
"autocfg",
"num-bigint 0.4.2",
"num-integer",
"num-traits",
]
@ -2494,6 +2540,15 @@ dependencies = [
"utils",
]
[[package]]
name = "subtitled25"
version = "0.1.0"
dependencies = [
"nannou",
"num 0.4.0",
"utils",
]
[[package]]
name = "subtitled3"
version = "0.1.0"

View File

@ -3,7 +3,3 @@
this is a bunch of nannou projects
i'll add a list with pictures here soon
you'll notice that the numbers i've put on fedi and the ones here are different :)
also don't criticize my code pls i'm sensitive and i Will cry

View File

@ -0,0 +1,9 @@
[package]
name = "subtitled25"
version = "0.1.0"
edition = "2018"
[dependencies]
nannou = "0.17"
num = "0.4.0"
utils = { path = "../utils" }

View File

@ -0,0 +1,50 @@
use nannou::prelude::*;
use num::complex::*;
use utils::*;
fn main() {
nannou::app(model)
.update(update)
.simple_window(view)
.size(800, 800)
.run();
}
struct Model {}
const BALL_SIZE: f32 = 3.0;
fn model(_app: &App) -> Model {
Model {}
}
fn update(app: &App, _model: &mut Model, _update: Update) {
let _t = app.elapsed_frames() as f32 / 60.0;
}
fn shader(i: usize, j: usize, w: usize, h: usize, t: f32) -> Hsl {
let x = (i as f32 / w as f32) - 0.5;
let y = (j as f32 / h as f32) - 0.5;
let x = x * 7.0;
let y = y * 7.0;
let mut v = Complex::new(y, x);
let a = map_sin(t * 0.5, 0.0, TAU);
let c = Complex::from_polar(0.7885, a);
let iters = map_sin(t * 0.1, 10.0, 100.0);
for i in 0..(iters as usize) {
v = v.powi(2) + c;
if v.norm() > 10.0 {
return hsl(i as f32 / iters, 0.5, 0.5);
}
}
hsl(0.0, 0.0, 0.0)
}
fn view(app: &App, _model: &Model, frame: Frame) {
utils::shaders::run(app, frame, BALL_SIZE, shader, vec2)
}

View File

@ -4,6 +4,7 @@ pub mod drawing;
pub mod lsystems;
pub mod record;
pub mod sequences;
pub mod shaders;
pub mod turtle;
use nannou::prelude::*;

View File

@ -0,0 +1,40 @@
use nannou::prelude::*;
pub fn run<S, T>(app: &App, frame: Frame, ball_size: f32, shader: S, tile_movement: T)
where
S: Fn(usize, usize, usize, usize, f32) -> Hsl,
T: Fn(f32, f32) -> Vec2,
{
let t = frame.nth() as f32 / 120.0;
let draw = app.draw();
draw.background().color(BLACK);
let (l, top, w, h) = app.window_rect().l_t_w_h();
let cols = (w / ball_size) as usize;
let rows = (h / ball_size) as usize;
for i in 0..cols {
for j in 0..rows {
let x = l + j as f32 * ball_size;
let y = top - i as f32 * ball_size;
let p = tile_movement(x, y);
let color = shader(i, j, cols, rows, t);
draw.quad()
.points(
p + ball_size * vec2(1., 1.),
p + ball_size * vec2(1., -1.),
p + ball_size * vec2(-1., -1.),
p + ball_size * vec2(-1., 1.),
)
.xy(p)
.color(color);
}
}
draw.to_frame(app, &frame).unwrap();
super::record::record(app, &frame);
}