-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from DavJCosby/master
catch new-api up to master
- Loading branch information
Showing
5 changed files
with
109 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
center_point = [1.5, 1.05] | ||
center_point = [0.0, 0.5] | ||
density = 30.0 | ||
|
||
[[line_segment]] | ||
start = [-1.0, 0.0] | ||
start = [-3.0, 0.0] | ||
end = [0.5, -1.0] | ||
|
||
[[line_segment]] | ||
start = [0.5, -1.0] | ||
end = [3.5, 0.0] | ||
|
||
[[line_segment]] | ||
start = [3.5, 0.0] | ||
end = [2, 2] | ||
|
||
[[line_segment]] | ||
start = [2, 2] | ||
end = [0.0, 2] | ||
|
||
[[line_segment]] | ||
start = [0.0, 2] | ||
end = [-1.0, 0.0] | ||
|
||
[[line_segment]] | ||
start = [0.25, 1.75] | ||
end = [2.5, 0.75] | ||
start = [2.0, 2] | ||
end = [-2.0, 2] | ||
|
||
[[line_segment]] | ||
start = [0.125, 0.25] | ||
end = [2.75, 0.25] | ||
start = [-2.0, 2] | ||
end = [-3.0, 0.0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use std::{f32::consts::TAU, time::Duration}; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use sled::{Rgb, Sled}; | ||
|
||
const GREEN_RADIUS: f32 = 35.0; | ||
const GREEN_COUNT: usize = 64; | ||
|
||
const BLUE_RADIUS: f32 = 45.0; | ||
const BLUE_COUNT: usize = 96; | ||
|
||
const TRAIL_RADIUS: f32 = 18.0; | ||
|
||
fn step(sled: &mut Sled, elapsed: f32) { | ||
let inner_color = Rgb::new(0.6, 0.93, 0.762); | ||
let outer_delta = Rgb::new(0.4, 0.51, 0.93); | ||
|
||
let inner_time_scale = elapsed / GREEN_RADIUS; | ||
let outer_time_scale = elapsed / BLUE_RADIUS; | ||
|
||
for i in 0..GREEN_COUNT { | ||
let angle = inner_time_scale + (TAU / GREEN_COUNT as f32) * i as f32; | ||
sled.get_at_angle_mut(angle).unwrap().color += inner_color; | ||
} | ||
|
||
for i in 0..BLUE_COUNT { | ||
let angle = outer_time_scale + (TAU / BLUE_COUNT as f32) * i as f32 % TAU; | ||
sled.get_at_angle_mut(angle).unwrap().color += outer_delta; | ||
} | ||
|
||
let radar_time_scale = elapsed / TRAIL_RADIUS; | ||
let angle = radar_time_scale % TAU; | ||
sled.map(|led| { | ||
let da = (led.angle() + angle) % TAU; | ||
let fac = 1.0 - (da / (TAU)).powf(1.25); | ||
led.color * fac | ||
}); | ||
} | ||
|
||
fn trail(c: &mut Criterion) { | ||
let mut sled = Sled::new("./benches/config1.toml").unwrap(); | ||
|
||
let simulated_duration = 30.0; | ||
let simulated_hz = 144.0; | ||
let timestep = 1.0 / simulated_hz; | ||
let total_steps = (simulated_duration * simulated_hz) as usize; | ||
|
||
c.bench_function("quirky_trail", |b| { | ||
b.iter(|| { | ||
for i in 0..total_steps { | ||
step(&mut sled, timestep * i as f32); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default() | ||
.significance_level(0.05) | ||
.sample_size(500) | ||
.warm_up_time(Duration::from_secs_f32(10.0)) | ||
.measurement_time(Duration::from_secs_f32(45.0)); | ||
targets = trail | ||
} | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
use sled::{Rgb, Sled, SledError}; | ||
|
||
|
||
// fn display | ||
|
||
fn main() { | ||
fn main() -> Result<(), SledError> { | ||
let mut sled = Sled::new("./benches/config1.toml").unwrap(); | ||
let white = Rgb::new(1.0, 1.0, 1.0); | ||
|
||
sled.set_range(20..50, white); | ||
} | ||
sled.set_range(20..50, white)?; | ||
Ok(()) | ||
} |