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

Method Split

path.go:1573–1591  ·  view source on GitHub ↗

Split splits the path into its independent subpaths. The path is split before each MoveTo command.

()

Source from the content-addressed store, hash-verified

1571
1572// Split splits the path into its independent subpaths. The path is split before each MoveTo command.
1573func (p *Path) Split() []*Path {
1574 if p == nil {
1575 return nil
1576 }
1577 var i, j int
1578 ps := []*Path{}
1579 for j < len(p.d) {
1580 cmd := p.d[j]
1581 if i < j && cmd == MoveToCmd {
1582 ps = append(ps, &Path{p.d[i:j:j]})
1583 i = j
1584 }
1585 j += cmdLen(cmd)
1586 }
1587 if i+cmdLen(MoveToCmd) < j {
1588 ps = append(ps, &Path{p.d[i:j:j]})
1589 }
1590 return ps
1591}
1592
1593// SplitAt splits the path into separate paths at the specified intervals (given in millimeters) along the path.
1594func (p *Path) SplitAt(ts ...float64) []*Path {

Callers 15

SettleMethod · 0.95
AndMethod · 0.95
OrMethod · 0.95
XorMethod · 0.95
NotMethod · 0.95
DivMethod · 0.95
RelateMethod · 0.95
IntersectionsMethod · 0.95
TouchesMethod · 0.95
OverlapsMethod · 0.95
ContainsMethod · 0.95

Calls 1

cmdLenFunction · 0.85

Tested by 4

TestPathSplitFunction · 0.64