MCPcopy Index your code
hub / github.com/Logicalshift/flo_curves

github.com/Logicalshift/flo_curves @0.7.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.7.3 ↗ · + Follow
984 symbols 5,505 edges 138 files 230 documented · 23%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
flo_curves = "0.7"

flo_curves

flo_curves is a library of routines for inspecting and manipulating curves, with a focus on cubic Bézier curves. In this library, you'll find routines for computing points on curves, performing collision detection between curves and lines or other curves, all the way up to routines for combining paths made up of multiple curves.

Anyone doing any work with Bézier curves will likely find something in this library that is of use, but its range of functions makes it particularly useful for collision detection or performing path arithmetic.

A set of curve and coordinate types are provided by the library, as well as a set of traits that can be implemented on any types with suitable properties. Implementing these traits makes it possible to add the extra features of this library to any existing code that has its own way of representing coordinates, curves or paths.

Examples

Creating a curve:

use flo_curves::*;
use flo_curves::bezier;

let curve = bezier::Curve::from_points(Coord2(1.0, 2.0), (Coord2(2.0, 0.0), Coord2(3.0, 5.0)), Coord2(4.0, 2.0));

Finding a point on a curve:

use flo_curves::bezier;

let pos = curve.point_at_pos(0.5);

Intersections:

use flo_curves::bezier;

for (t1, t2) in bezier::curve_intersects_curve_clip(curve1, curve2, 0.01) {
    let pos = curve1.point_at_pos(t1);
    println!("Intersection, curve1 t: {}, curve2 t: {}, position: {}, {}", t1, t2, pos.x(), pos.y());
}

Creating a path:

use flo_curves::bezier;
use flo_curves::bezier::path::*;

let rectangle1 = 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();

Path arithmetic:

use flo_curves::bezier::path::*;

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

flo_curves logo

Extension points exported contracts — how you extend this code

Geo (Interface)
Simple base trait implemented by things representing geometry [9 implementers]
src/geo/geo.rs
BezierCurve (Interface)
Trait implemented by things representing a cubic bezier curve [4 implementers]
src/bezier/curve.rs
Line (Interface)
Represents a straight line [1 implementers]
src/line/line.rs
HasBoundingBox (Interface)
Trait implemented by types that have a bounding box associated with them [4 implementers]
src/geo/has_bounds.rs
RayPath (Interface)
Represents a path that can be accessed by the ray collision algorithm [2 implementers]
src/bezier/path/ray.rs
Line2D (Interface)
Trait implemented by a 2D line [1 implementers]
src/line/line.rs
Coordinate (Interface)
Represents a value that can be used as a coordinate in a bezier curve [2 implementers]
src/geo/coordinate.rs
Normalize (Interface)
Changes a point and its tangent into a normal [1 implementers]
src/bezier/normal.rs

Core symbols most depended-on inside this repo

line_to
called by 803
src/bezier/path/path_builder.rs
curve_to
called by 538
src/bezier/path/path_builder.rs
point_at_pos
called by 218
src/bezier/section.rs
x
called by 218
src/geo/coordinate.rs
build
called by 192
src/bezier/path/path_builder.rs
y
called by 167
src/geo/coordinate.rs
len
called by 161
src/geo/coordinate.rs
start_point
called by 100
src/bezier/curve.rs

Shape

Function 692
Method 232
Class 29
Interface 19
Enum 12

Languages

Rust100%

Modules by API surface

tests/bezier/path/graph_path.rs52 symbols
src/bezier/path/graph_path/mod.rs43 symbols
src/bezier/characteristics.rs40 symbols
tests/bezier/curve_intersection_clip.rs39 symbols
tests/bezier/path/arithmetic_add.rs31 symbols
src/bezier/intersection/fat_line.rs31 symbols
src/geo/coordinate.rs28 symbols
tests/bezier/intersection.rs27 symbols
src/bezier/curve.rs26 symbols
src/bezier/path/ray.rs25 symbols
tests/bezier/path/arithmetic_sub.rs24 symbols
tests/bezier/path/rays.rs22 symbols

For agents

$ claude mcp add flo_curves \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact