Draws a polygon via `rasops`.
(rasops: &mut R, points: &[PixelsXY])
| 275 | |
| 276 | /// Draws a polygon via `rasops`. |
| 277 | pub fn draw_poly<R>(rasops: &mut R, points: &[PixelsXY]) -> io::Result<()> |
| 278 | where |
| 279 | R: RasterOps + ?Sized, |
| 280 | { |
| 281 | if points.len() < 2 { |
| 282 | return Ok(()); |
| 283 | } |
| 284 | |
| 285 | for i in 1..points.len() { |
| 286 | rasops.draw_line(points[i - 1], points[i])?; |
| 287 | } |
| 288 | rasops.draw_line(*points.last().expect("At least 2 points are present"), points[0])?; |
| 289 | Ok(()) |
| 290 | } |
| 291 | |
| 292 | /// Calculates the x-coordinate intersection of a horizontal scanline with a line segment. |
| 293 | /// |