move inputs to separate file & add Animation trait
This commit is contained in:
parent
eb42f5fa54
commit
783631182c
4 changed files with 34 additions and 19 deletions
24
src/inputs.rs
Normal file
24
src/inputs.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
use {
|
||||||
|
std::time::Duration,
|
||||||
|
crate::waveform::Waveform
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Inputs {
|
||||||
|
pub t: Duration,
|
||||||
|
pub transition_time: Duration,
|
||||||
|
|
||||||
|
pub scene_select: usize,
|
||||||
|
pub cycle_len: Duration,
|
||||||
|
pub wave_peak: f32,
|
||||||
|
|
||||||
|
pub master_wave: Option< Waveform >,
|
||||||
|
pub master_subdivision: i32,
|
||||||
|
pub master_intensity: f32,
|
||||||
|
pub wheel: i32,
|
||||||
|
pub wheel2: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -16,6 +16,7 @@ use {
|
||||||
mod util;
|
mod util;
|
||||||
mod fixture;
|
mod fixture;
|
||||||
mod setup;
|
mod setup;
|
||||||
|
mod inputs;
|
||||||
mod view;
|
mod view;
|
||||||
mod stripe_driver;
|
mod stripe_driver;
|
||||||
mod jack;
|
mod jack;
|
||||||
|
@ -32,25 +33,10 @@ use crate::{
|
||||||
util::get_angle,
|
util::get_angle,
|
||||||
|
|
||||||
scene_library::SceneLibrary,
|
scene_library::SceneLibrary,
|
||||||
waveform::Waveform
|
waveform::Waveform,
|
||||||
|
inputs::Inputs
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Inputs {
|
|
||||||
t: Duration,
|
|
||||||
transition_time: Duration,
|
|
||||||
|
|
||||||
scene_select: usize,
|
|
||||||
cycle_len: Duration,
|
|
||||||
wave_peak: f32,
|
|
||||||
|
|
||||||
master_wave: Option< Waveform >,
|
|
||||||
master_subdivision: i32,
|
|
||||||
master_intensity: f32,
|
|
||||||
wheel: i32,
|
|
||||||
wheel2: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let event_loop = EventLoop::new().unwrap();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
|
|
|
@ -17,7 +17,6 @@ pub struct ArcticRain { pub inputs: Arc<RwLock< Inputs >> }
|
||||||
impl ColorGrid for ArcticRain {
|
impl ColorGrid for ArcticRain {
|
||||||
fn get(&self, p: &Vector2<f32>) -> Rgb<f32> {
|
fn get(&self, p: &Vector2<f32>) -> Rgb<f32> {
|
||||||
let inputs = self.inputs.read().unwrap().clone();
|
let inputs = self.inputs.read().unwrap().clone();
|
||||||
// let millis = self
|
|
||||||
|
|
||||||
let i = ( inputs.t.as_millis() as f32 / (4.0*inputs.cycle_len.as_millis() as f32) ) % 1.0;
|
let i = ( inputs.t.as_millis() as f32 / (4.0*inputs.cycle_len.as_millis() as f32) ) % 1.0;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
use {
|
use {
|
||||||
cgmath::Vector2,
|
cgmath::Vector2,
|
||||||
prisma::Rgb
|
prisma::Rgb,
|
||||||
|
|
||||||
|
crate::inputs::Inputs
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait ColorGrid {
|
pub trait ColorGrid {
|
||||||
fn get(&self, pos: &Vector2<f32>) -> Rgb<f32>;
|
fn get(&self, pos: &Vector2<f32>) -> Rgb<f32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait Animation {
|
||||||
|
fn advance(&mut self, inputs: Inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue