Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 1.09 KB

File metadata and controls

35 lines (23 loc) · 1.09 KB

Drawing Circles

To draw a circle, we can use draw_filled_circle_mut. The function needs the center position and the radius of the circle.

use imageproc::{drawing, image};

fn main() {
    let mut buf = image::ImageBuffer::new(100, 100);

    drawing::draw_filled_circle_mut(
        &mut buf,
        (50, 50),
        30,
        image::Rgb::from([128u8, 255u8, 64u8]),
    );

    buf.save("circle.png").unwrap();
}

circle.png:

circle

To only draw the border, we can use draw_hollow_circle_mut.

circle_hollow

To draw on a copied image, we can use draw_filled_circle and draw_hollow_circle.

➡️ Next: Drawing Ellipses

📘 Back: Table of contents