From 5ca0021533bbcd378875101cea7cd12b660f93e0 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 15 Mar 2023 12:34:57 +0100 Subject: [PATCH] Fix: favicon --- src/polygon.rs | 36 ------------------------------------ src/routes/favicon.rs | 2 +- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/polygon.rs b/src/polygon.rs index da740f3..02343b1 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -44,29 +44,6 @@ fn generate_colors(rng: &mut ThreadRng) -> (Color, Color) { (Color::from_hex(c1), Color::from_hex(c2)) } -pub fn draw_polygon( - center: (f64, f64), - side_length: f64, - num_sides: i32, - context: &Context, -) -> Result<(), cairo::Error> { - let mut rng = rand::thread_rng(); - let (c1, _) = generate_colors(&mut rng); - set_color(c1, context); - context.new_path(); - - let corners = calculate_polygon_corners(center, num_sides, side_length, 30.0); - - for (x, y) in corners { - context.line_to(x, y); - } - - context.close_path(); - context.fill()?; - - Ok(()) -} - pub fn draw_segmented_polygon( center: (f64, f64), side_length: f64, @@ -121,16 +98,3 @@ pub fn draw_polygon_of_segmented_polygons( } Ok(()) } - -pub fn draw_polygon_of_polygons( - center: (f64, f64), - radius: f64, - num_sides: i32, - context: &Context, -) -> Result<(), cairo::Error> { - let corners = calculate_polygon_corners(center, num_sides, radius, 0.0); - for corner in corners { - draw_polygon(corner, radius * 0.4, num_sides, &context)?; - } - Ok(()) -} diff --git a/src/routes/favicon.rs b/src/routes/favicon.rs index 620544c..05ccfa2 100644 --- a/src/routes/favicon.rs +++ b/src/routes/favicon.rs @@ -10,7 +10,7 @@ async fn handler() -> impl axum::response::IntoResponse { 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).unwrap(); + polygon::draw_polygon_of_segmented_polygons((50.0, 50.0), 37.0, 16.75, 6, &context).unwrap(); let mut data: Vec = Vec::new(); surface.write_to_png(&mut data).unwrap();