diff --git a/crates/api_clients/grok_client/src/requests/index_page/signature/signature_simulate_style.rs b/crates/api_clients/grok_client/src/requests/index_page/signature/signature_simulate_style.rs index 01cc7a5178..49555d720c 100644 --- a/crates/api_clients/grok_client/src/requests/index_page/signature/signature_simulate_style.rs +++ b/crates/api_clients/grok_client/src/requests/index_page/signature/signature_simulate_style.rs @@ -1,6 +1,8 @@ +use log::error; use crate::error::grok_client_error::GrokClientError; use once_cell::sync::Lazy; use regex::Regex; +use crate::requests::index_page::signature::signature_cubic_bezier_eased::signature_cubic_bezier_eased; use crate::requests::index_page::signature::signature_h::signature_h; static CLEAN_NON_DIGIT_REGEX : Lazy = Lazy::new(|| { @@ -103,7 +105,48 @@ pub fn signature_simulate_style(values: &[u32], c: u32) -> Result easedY -0.06687371608353283 + println!("eased_y = {:?}", eased_y); + + // NB: Safety + if values.len() < 6 { + error!("Values array is too short."); + return Err(GrokClientError::BadSignatureInputs); + } + + // start = [float(x) for x in values[0:3]] + let start = values[0..3].iter().map(|x| *x as f64).collect::>(); + + // end = [float(x) for x in values[3:6]] + let end = values[3..6].iter().map(|x| *x as f64).collect::>(); + + // > start [73.0, 44.0, 215.0] + // > end [158.0, 218.0, 29.0] + println!("start = {:?}", start); + println!("end = {:?}", end); + + // r = round(start[0] + (end[0] - start[0]) * easedY) + // g = round(start[1] + (end[1] - start[1]) * easedY) + // b = round(start[2] + (end[2] - start[2]) * easedY) + + let r = (start[0] + (end[0] - start[0]) * eased_y).round() as u32; + let g = (start[1] + (end[1] - start[1]) * eased_y).round() as u32; + let b = (start[2] + (end[2] - start[2]) * eased_y).round() as u32; + + // color = f"rgb({r}, {g}, {b})" + let color = format!("rgb({r}, {g}, {b})"); + + // > r 67 + // > g 32 + // > b 227 + // > color rgb(67, 32, 227) + println!("color = {:?}", color); Ok(SimulatedStyle {