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:
To draw only the border, we can use draw_hollow_ellipse_mut.
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