Module flo_curves::bezier::path

source ·
Expand description

Manipulates multiple Bezier curves joined into a path

let rectangle = BezierPathBuilder::<SimpleBezierPath>::start(Coord2(1.0, 1.0))
    .line_to(Coord2(5.0, 1.0))
    .line_to(Coord2(5.0, 5.0))
    .line_to(Coord2(1.0, 5.0))
    .line_to(Coord2(1.0, 1.0))
    .build();
let circle = Circle::new(Coord2(3.0, 3.0), 1.0).to_path::<SimpleBezierPath>();

let rectangle_with_hole = path_sub::<SimpleBezierPath>(&vec![rectangle], &vec![circle], 0.01);

Anything that implements the BezierPath trait can be treated as a path. The SimpleBezierPath type is provided as a convenient default implementation of this trait. These paths represent a single perimeter of a region.

The arithmetic operations such as path_sub(), path_add(), path_intersect() all work with collections of these perimeters, stored in a Vec. A path with a hole in the middle will have two perimeters, for example.

These perimeters must not be self-intersecting: flo_curves doesn’t use a winding rule as such but instead considers all edges to be exterior edges (which is very similar to an even-odd winding rule). A couple of methods are provided for fixing paths with self-intersections: path_remove_interior_points() will find the outermost perimeter of a shape - which is useful for tidying up the subpaths. path_remove_overlapped_points() will combine subpaths so that there are no overlapping edges. These two functions provide much finer control than is possible through the traditional idea of the winding rule.

There are a few more advanced algorithms: for example, the flood_fill_concave() function provides a vector implementation of the flood fill algorithm, returning a path that fills a space defined by a ray-casting function.

Modules

Structs

  • Used to build a bezier path
  • Represents an edge in a graph path
  • Reference to a graph edge
  • A graph path is a path where each point can have more than one connected edge. Edges are categorized into interior and exterior edges depending on if they are on the outside or the inside of the combined shape.
  • The result of a path cut operation
  • The result of a path cut operation
  • Label attached to a path used for arithmetic

Enums

Traits

  • Trait representing a path made out of bezier sections
  • Trait implemented by types that can construct new bezier paths
  • Trait implemented by paths that can determine if their points are in a clockwise ordering or not

Functions

  • Generates the path formed by adding two sets of paths
  • Adds multiple paths in a single operation
  • Finds the bounds of a path
  • Performs a series of path combining operations to generate an output path
  • Returns true if a particular point is within a bezier path
  • Cuts a path (path1) into two along another path (path2), returning the part of path1 that was interior to path2 and the part that was exterior in one operation
  • Finds the bounds of a path using the looser ‘fast’ algorithm
  • Intersects two paths, returning both the path that is the intersection and the paths that are outside
  • Generates the path formed by intersecting two sets of paths
  • Determines the intersections of a path and a line
  • Finds the points where a path intersects another path
  • Determines the intersections of a path and a ray.
  • Generates the path formed by removing any interior points from an existing path. This considers only the outermost edges of the path to be the true edges, so if there are sub-paths inside an outer path, they will be removed.
  • Generates the path formed by removing any interior points from an existing path. This considers all edges to be exterior edges and will remove those that are obscured by another part of the path.
  • Generates the path formed by subtracting two sets of paths
  • Converts a path to a series of bezier curves
  • Determines if a set of points are in a clockwise ordering (assuming that a positive y value indicates an upwards direction)

Type Definitions