Ok(response_image!(cursor))
}
+#[get("/pgen/4/{dim_x}/{dim_y}/{scale}/{wave_offset_x}/{wave_offset_y}/{amplitude}/{freq}/{run}/{wave_color}/{data}")]
+#[allow(clippy::type_complexity)]
+async fn img_pgen4(req: HttpRequest, path: web::Path<(u32, u32, u32, u32, u32, f32, f32, u32)>,
+ canvas1: web::Data<Arc<Mutex<Canvas1>>>) -> Result<impl Responder>
+{
+ let (dim_x, dim_y, scale, wave_offset_x, wave_offset_y, amplitude, freq_base, run) = path.into_inner();
+ let freq_base = freq_base / 1000.0;
+ let wave_color = extract_color!(req, 11)?;
+ let data = extract_data!(req, 12);
+ let img: RgbImage = ({
+ let canvas_option = &mut *canvas1.lock().unwrap();
+ Ok(apply_to_canvas(
+ |mut canvas, signal| {
+ canvas.img = sine_encode(canvas.img, (wave_offset_x, wave_offset_y), amplitude, freq_base, run, wave_color, signal)?;
+ Ok(canvas)
+ },
+ &mut canvas_option.0, Some((dim_x, dim_y)), data)?.img.clone())
+ } as Result<RgbImage, CanvasError>)?;
+ let cursor = image_to_cursor(img, scale)?;
+ Ok(response_image!(cursor))
+}
+
#[get("/pdrop/{canvas_id}")]
async fn pdrop(canvas_id: web::Path<u8>,
canvas0: web::Data<Arc<Mutex<Canvas0>>>,
.service(img_pgen1)
.service(img_pgen2)
.service(img_pgen3)
+ .service(img_pgen4)
.service(pdrop)
.app_data(web::Data::new(canvas0.clone()))
.app_data(web::Data::new(canvas1.clone()))