Package-level declarations

Functions

Link copied to clipboard
fun distortedSegment(curve: Segment2D, samples: Int = 40, errorTolerance: Double = 0.5, maxDepth: Int = 8, distort: (Vector2) -> Vector2): List<Segment2D>

Same idea as before: sample the curve, distort each sample, fit tangent-continuous beziers to the result.

Link copied to clipboard
fun fitCubicBeziers(points: List<Vector2>, errorTolerance: Double = 1.0, maxDepth: Int = 10, minPointsToSplit: Int = 5, tangentWindow: Int = 1, preferLowCurvatureSplits: Boolean = true, curvatureSearchRadius: Int = 3, cornerAngle: Double? = null, closed: Boolean = false): List<Segment2D>

Fits a polyline of points with one or more cubic Beziers, splitting wherever a single piece can't stay within errorTolerance, after Schneider, "An algorithm for automatically fitting digitized curves" (Graphics Gems, 1990):

Link copied to clipboard
fun List<Segment2D>.toContour(closed: Boolean = false): ShapeContour

Stitch the fitted pieces into a single contour, e.g. for drawing; closed for the pieces of a closed fit.