Compare commits

...

2 Commits

Author SHA1 Message Date
Marc Planard 69b619dbf5 black working 2023-07-06 22:58:24 +02:00
Marc Planard 21bc0496c2 kpps working 2023-07-06 22:22:56 +02:00
3 changed files with 30 additions and 7 deletions

View File

@ -16,7 +16,7 @@ use std::sync::Arc;
use redis_ctrl::{RedisCtrl, Order};
use conf::Conf;
use errors::LJResult;
use point::Point;
use point::{Point,Color};
use transformer::Transformers;
use log::{LevelFilter, info, /* warn, */ error};
use env_logger::Builder;
@ -87,9 +87,10 @@ fn run_all() -> LJResult<()> {
// 6 : Max Intensity Change = reread redis key /intensity
// 7 : kpps change = reread redis key /kpps
// 8 : color balance change = reread redis keys /red /green /blue
match order {
Order::Draw => {
Order::Draw | Order::Black => {
world_state.black = order == Order::Black;
let frame = get_next_frame(
&config,
&transformers,
@ -155,6 +156,27 @@ fn get_next_frame(
for transformer in transformers {
line = transformer.apply(&line, world_state);
}
info!("-> {}", world_state.black);
// LIMITER and BLACK
line = line.into_iter()
.map(| p | {
let color = if world_state.black {
Color { r: 0, g: 0, b: 0 }
} else {
Color {
r: p.color.r.min(world_state.intensity),
g: p.color.g.min(world_state.intensity),
b: p.color.b.min(world_state.intensity)
}
};
Point { color,
..p
}
})
.collect();
//info!("Line: {:?}", line);
Ok(line)

View File

@ -7,9 +7,9 @@ pub struct Point {
#[derive(Debug,Clone,Copy,Default,PartialEq)]
pub struct Color {
r: u8,
g: u8,
b: u8
pub r: u8,
pub g: u8,
pub b: u8
}
impl From<(f32,f32,u32)> for Point {

View File

@ -43,7 +43,8 @@ pub struct WorldState {
pub client_key: String, //u8,
pub intensity: u8,
pub kpps: u32,
pub color: Color
pub color: Color,
pub black: bool
}
impl WorldState {