Stroke converts a path into a stroke of width w and returns a new path. It uses cr to cap the start and end of the path, and jr to join all path elements. If the path closes itself, it will use a join between the start and end instead of capping them. The tolerance is the maximum deviation from the
(w float64, cr Capper, jr Joiner, tolerance float64)
| 656 | |
| 657 | // Stroke converts a path into a stroke of width w and returns a new path. It uses cr to cap the start and end of the path, and jr to join all path elements. If the path closes itself, it will use a join between the start and end instead of capping them. The tolerance is the maximum deviation from the original path when flattening Béziers and optimizing the stroke. |
| 658 | func (p *Path) Stroke(w float64, cr Capper, jr Joiner, tolerance float64) *Path { |
| 659 | if cr == nil { |
| 660 | cr = ButtCap |
| 661 | } |
| 662 | if jr == nil { |
| 663 | jr = MiterJoin |
| 664 | } |
| 665 | |
| 666 | q := &Path{} |
| 667 | halfWidth := math.Abs(w) / 2.0 |
| 668 | for _, pi := range p.Split() { |
| 669 | rhs, lhs := pi.offset(halfWidth, cr, jr, true, tolerance) |
| 670 | if rhs != nil { |
| 671 | q = q.Append(rhs).Append(lhs.Reverse()) |
| 672 | } |
| 673 | } |
| 674 | if !FastStroke { |
| 675 | // fix overlapping and spilled parts |
| 676 | q = q.Settle(Positive) |
| 677 | } |
| 678 | return q |
| 679 | } |
no test coverage detected