Ok(response_image!(cursor))
}
+#[get("/gen/5/{dim_x}/{dim_y}/{scale}/{offset_x}/{offset_y}/{run}/{color}/{data}")]
+async fn img_gen5(req: HttpRequest, path: web::Path<(u32, u32, u32, u32, u32, u32)>) -> Result<impl Responder> {
+ let (dim_x, dim_y, scale, offset_x, offset_y, run) = path.into_inner();
+ let color = extract_color!(req, 9)?;
+ let data = &mut percent_decode_str(extract_data!(req, 10));
+ let cursor = make_png(dim_x, dim_y, scale, data,
+ |mut img, data| {
+ let mut x = offset_x;
+ let mut data = data.peekable();
+ while (x < img.width()) && (data.peek().is_some()) {
+ let v = data.next().unwrap_or(0);
+ let y = offset_y + v as u32;
+ let max_x = if (x + run) < img.width() { x + run } else { img.width() };
+ while x < max_x {
+ if y < img.height() {
+ img.put_pixel(x, offset_y + v as u32, color);
+ }
+ x += 1;
+ }
+ }
+ Ok(img)
+ })?;
+ Ok(response_image!(cursor))
+}
+
#[get("/pgen/0/{data}")]
async fn img_pgen0(req: HttpRequest, canvas0: web::Data<Arc<Mutex<Canvas0>>>) -> Result<impl Responder> {
let data = extract_data!(req, 3);
.service(img_gen2)
.service(img_gen3)
.service(img_gen4)
+ .service(img_gen5)
.service(img_pgen0)
.service(img_pgen1)
.service(img_pgen2)