Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.2 KB

drawing_ellipses.md

File metadata and controls

37 lines (25 loc) · 1.2 KB

Drawing Ellipses

Ellipses are circles that have different width and height. We can use draw_filled_ellipse_mut to draw an ellipse. It needs the center point of the ellipse, the width, the height and the color.

use imageproc::{drawing, image};

fn main() {
    let mut buf = image::ImageBuffer::new(100, 100);
    
    drawing::draw_filled_ellipse_mut(
        &mut buf,
        (50, 50),
        30,
        20,
        image::Rgb::from([128u8, 255u8, 64u8]),
    );

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

ellipse.png:

ellipse

To draw only the border, we can use draw_hollow_ellipse_mut.

ellipse_hollow

To draw an ellipse on a copied image, we can use draw_filled_ellipse and draw_hollow_ellipse.

➡️ Next: Drawing Crosses

📘 Back: Table of contents