MCPcopy Create free account
hub / github.com/cogentcore/core / AddTo

Method AddTo

paint/raster/geom.go:130–155  ·  view source on GitHub ↗

AddTo adds the Path p to q.

(q Adder)

Source from the content-addressed store, hash-verified

128
129// AddTo adds the Path p to q.
130func (p Path) AddTo(q Adder) {
131 for i := 0; i < len(p); {
132 switch PathCommand(p[i]) {
133 case PathMoveTo:
134 q.Stop(false) // Fixes issues #1 by described by Djadala; implicit close if currently in path.
135 q.Start(fixed.Point26_6{X: p[i+1], Y: p[i+2]})
136 i += 3
137 case PathLineTo:
138 q.Line(fixed.Point26_6{X: p[i+1], Y: p[i+2]})
139 i += 3
140 case PathQuadTo:
141 q.QuadBezier(fixed.Point26_6{X: p[i+1], Y: p[i+2]}, fixed.Point26_6{X: p[i+3], Y: p[i+4]})
142 i += 5
143 case PathCubicTo:
144 q.CubeBezier(fixed.Point26_6{X: p[i+1], Y: p[i+2]},
145 fixed.Point26_6{X: p[i+3], Y: p[i+4]}, fixed.Point26_6{X: p[i+5], Y: p[i+6]})
146 i += 7
147 case PathClose:
148 q.Stop(true)
149 i++
150 default:
151 panic("AddTo: bad path")
152 }
153 }
154 q.Stop(false)
155}
156
157// ToLength scales the point to the length indicated by ln
158func ToLength(p fixed.Point26_6, ln fixed.Int26_6) (q fixed.Point26_6) {

Callers 8

StrokePreserveMethod · 0.80
FillPreserveMethod · 0.80
BenchmarkScanFunction · 0.80
BenchmarkFillFunction · 0.80
BenchmarkDashFunction · 0.80
TestShapesFunction · 0.80
TestGradientFunction · 0.80
TestMultiFunctionFunction · 0.80

Calls 6

PathCommandTypeAlias · 0.85
StopMethod · 0.65
StartMethod · 0.65
LineMethod · 0.65
QuadBezierMethod · 0.65
CubeBezierMethod · 0.65

Tested by 6

BenchmarkScanFunction · 0.64
BenchmarkFillFunction · 0.64
BenchmarkDashFunction · 0.64
TestShapesFunction · 0.64
TestGradientFunction · 0.64
TestMultiFunctionFunction · 0.64