+#[get("/gen/4/{scale}")]
+async fn img_gen4(req: HttpRequest, path: web::Path<u32>) -> Result<impl Responder> {
+ let scale = path.into_inner();
+ let signal = &mut extract_header!(req, "user-agent").bytes();
+ let mut resimg: RgbImage = ImageBuffer::new(1600, 600);
+ let mut x: f32 = 0.0;
+ let max_x: f32 = (resimg.width() - 1) as f32;
+ //let max_y: f32 = (resimg.height() - 1) as f32;
+ let run: f32 = 20.0;
+ let amplitude: f32 = 200.0;
+ let wave_offset: f32 = (resimg.height() / 2) as f32 + amplitude / 2.0 - 1.0;
+ let freq_base: f32 = 50.0;
+ while x < max_x {
+ let px = x;
+ let s = signal.next().unwrap_or(0);
+ warn!("Next char: {:>1} {:#02X}", s as char, s);
+ while ((x - px) < run) && (x < max_x) {
+ let y = if s != 0 {
+ (x / (freq_base / s as f32)).sin() * amplitude + wave_offset
+ }
+ else { wave_offset };
+ x += 0.001;
+ debug!("{x}, {y}");
+ resimg.put_pixel(x as u32, y as u32, Rgb([255, 255, 255]));
+ resimg.put_pixel(x as u32, s.into(), Rgb([255, 0, 0]));
+ }
+ }
+ let cursor = image_to_cursor(resimg, scale)?;
+ Ok(response_image!(cursor))
+}
+