26 lines
751 B
Rust
26 lines
751 B
Rust
use axum::{routing::get, Router};
|
|
use cairo::{Context, Format, ImageSurface};
|
|
|
|
use crate::{polygon, SharedState};
|
|
|
|
async fn handler() -> impl axum::response::IntoResponse {
|
|
let surface = ImageSurface::create(Format::ARgb32, 100, 100).unwrap();
|
|
let context = Context::new(&surface).unwrap();
|
|
|
|
context.set_source_rgba(0.0, 0.0, 0.0, 0.0);
|
|
context.fill().unwrap();
|
|
|
|
polygon::draw_polygon_of_polygons((50.0, 50.0), 65.0, 6, &context, false);
|
|
|
|
let mut data: Vec<u8> = Vec::new();
|
|
surface.write_to_png(&mut data).unwrap();
|
|
|
|
(
|
|
axum::response::AppendHeaders([(axum::http::header::CONTENT_TYPE, "image/png")]),
|
|
data,
|
|
)
|
|
}
|
|
|
|
pub fn routes() -> Router<SharedState> {
|
|
Router::new().route("/", get(handler))
|
|
}
|