MCPcopy Index your code
hub / github.com/endbasic/endbasic / draw_poly

Function draw_poly

std/src/console/drawing.rs:277–290  ·  view source on GitHub ↗

Draws a polygon via `rasops`.

(rasops: &mut R, points: &[PixelsXY])

Source from the content-addressed store, hash-verified

275
276/// Draws a polygon via `rasops`.
277pub fn draw_poly<R>(rasops: &mut R, points: &[PixelsXY]) -> io::Result<()>
278where
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///

Callers 5

draw_polyMethod · 0.85
draw_poly_filledFunction · 0.85
draw_polyMethod · 0.85
test_draw_polyFunction · 0.85
draw_polyMethod · 0.85

Calls 3

lastMethod · 0.80
lenMethod · 0.45
draw_lineMethod · 0.45

Tested by 1

test_draw_polyFunction · 0.68