Split splits the path into its independent subpaths. The path is split before each MoveTo command.
()
| 1571 | |
| 1572 | // Split splits the path into its independent subpaths. The path is split before each MoveTo command. |
| 1573 | func (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. |
| 1594 | func (p *Path) SplitAt(ts ...float64) []*Path { |