Path Manipulation

General path manipulation can be performed on the Polygonarrow-up-right 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 Fbmarrow-up-right 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