MCPcopy
hub / github.com/tdewolff/canvas / Flatten

Method Flatten

path.go:1448–1459  ·  view source on GitHub ↗

Flatten flattens all Bézier and arc curves into linear segments and returns a new path. It uses tolerance as the maximum deviation.

(tolerance float64)

Source from the content-addressed store, hash-verified

1446
1447// Flatten flattens all Bézier and arc curves into linear segments and returns a new path. It uses tolerance as the maximum deviation.
1448func (p *Path) Flatten(tolerance float64) *Path {
1449 quad := func(p0, p1, p2 Point) *Path {
1450 return flattenQuadraticBezier(p0, p1, p2, tolerance)
1451 }
1452 cube := func(p0, p1, p2, p3 Point) *Path {
1453 return flattenCubicBezier(p0, p1, p2, p3, tolerance)
1454 }
1455 arc := func(start Point, rx, ry, phi float64, large, sweep bool, end Point) *Path {
1456 return flattenEllipticArc(start, rx, ry, phi, large, sweep, end, tolerance)
1457 }
1458 return p.replace(nil, quad, cube, arc)
1459}
1460
1461// ReplaceArcs replaces ArcTo commands by CubeTo commands and returns a new path.
1462func (p *Path) ReplaceArcs() *Path {

Callers 7

DrawPreviewWithAssetsFunction · 0.80
bentleyOttmannFunction · 0.80
relateFunction · 0.80
flattenEllipticArcFunction · 0.80
PolylineFromPathFunction · 0.80
draw2Function · 0.80
drawFunction · 0.80

Calls 4

replaceMethod · 0.95
flattenQuadraticBezierFunction · 0.85
flattenCubicBezierFunction · 0.85
flattenEllipticArcFunction · 0.85

Tested by

no test coverage detected