Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Path Manipulation

General path manipulation can be performed on the Polygon type. We can construct a Polygon from any type implementing Iterator<Item=P2>, which Ngon does.

let square = Polygon::from(Ngon::square(world.center(), 200.));
canvas.paint(Filled(square));

Polygon provides an iterator over its vertices we can use to manipulate them, and build a new polygon. In this code we use that to distort the polygon by sampling Fbm noise with time as the z position:

A square whose vertices are translated by noise.

Further, we can iteratively subdivide and apply this same distortion to make more interesting shapes:

An animated low-poly cloth.

Last updated