use actix_web::http::StatusCode;
use image::{ImageBuffer, ColorType, Rgb, RgbImage, write_buffer_with_format};
use image::ImageOutputFormat::Png;
-use image::imageops::{FilterType, resize};
+use image::imageops::{FilterType, overlay, resize};
use image::error::{LimitError, LimitErrorKind};
+use actix_web::cookie::time::OffsetDateTime;
#[derive(Debug)]
.body(cursor.into_inner()))
}
+#[get("/gen/3/{scale}")]
+async fn img_gen3(req: HttpRequest, path: web::Path<u32>) -> Result<impl Responder> {
+ let scale = path.into_inner();
+ let data = match req.headers().get("user-agent") {
+ Some(header) => header.to_str().unwrap_or(""),
+ _ => ""
+ };
+ let rgbimg: RgbImage = rgb_encode(ImageBuffer::new(6, 6), &mut data.bytes())?;
+ let mut resimg: RgbImage = ImageBuffer::new(60 * 6, 24 * 6);
+ let time = OffsetDateTime::now_utc().time();
+ overlay(&mut resimg, &rgbimg, (time.minute() * 6).into(), (time.hour() * 6).into());
+ let cursor = image_to_cursor(resimg, scale)?;
+ Ok(HttpResponse::build(StatusCode::OK)
+ .content_type("image/png")
+ .body(cursor.into_inner()))
+}
+
#[get("/pgen/0/{data}")]
async fn img_pgen0(req: HttpRequest, canvas0: web::Data<Arc<Mutex<Canvas0>>>) -> Result<impl Responder> {
let data = req.uri().path().split("/").skip(3).next().unwrap();
.service(img_gen0)
.service(img_gen1)
.service(img_gen2)
+ .service(img_gen3)
.service(img_pgen0)
.service(img_pgen1)
.service(img_pgen2)