diff --git a/src/polygon.rs b/src/polygon.rs index 5e690d9..972ca63 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -60,6 +60,28 @@ fn generate_color( color } +pub fn draw_polygon( + center: (f64, f64), + side_length: f64, + num_sides: i32, + context: &Context, + dark_mode: bool, +) { + let mut rng = rand::thread_rng(); + let c1 = generate_color(&mut rng, dark_mode, None); + set_color_i8(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().unwrap(); +} + pub fn draw_segmented_polygon( center: (f64, f64), side_length: f64, @@ -101,7 +123,7 @@ pub fn draw_segmented_polygon( context.fill().unwrap(); } -pub fn draw_polygon_of_polygons( +pub fn draw_polygon_of_segmented_polygons( center: (f64, f64), side_length: f64, num_sides: i32, @@ -113,3 +135,16 @@ pub fn draw_polygon_of_polygons( draw_segmented_polygon(corner, side_length * 0.4, num_sides, &context, dark_mode); } } + +pub fn draw_polygon_of_polygons( + center: (f64, f64), + side_length: f64, + num_sides: i32, + context: &Context, + dark_mode: bool, +) { + let corners = calculate_polygon_corners(center, num_sides, side_length, 0.0); + for corner in corners { + draw_polygon(corner, side_length * 0.4, num_sides, &context, dark_mode); + } +} diff --git a/src/routes/logo.rs b/src/routes/logo.rs index ffa38b2..33cb401 100644 --- a/src/routes/logo.rs +++ b/src/routes/logo.rs @@ -26,7 +26,13 @@ async fn handler(Query(properties): Query) -> impl axum::respon context.paint().unwrap(); - polygon::draw_polygon_of_polygons((200.0, 200.0), 200.0, 6, &context, properties.dark_mode); + polygon::draw_polygon_of_segmented_polygons( + (200.0, 200.0), + 200.0, + 6, + &context, + properties.dark_mode, + ); let mut data: Vec = Vec::new(); surface.write_to_png(&mut data).unwrap();