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

Method Stroke

path_stroke.go:658–679  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
658func (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}

Callers 10

DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
DecorateMethod · 0.95
RenderPathMethod · 0.95
drawFunction · 0.95

Calls 5

SplitMethod · 0.95
AppendMethod · 0.95
SettleMethod · 0.95
offsetMethod · 0.80
ReverseMethod · 0.45

Tested by

no test coverage detected