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

Method CubeTo

path.go:473–491  ·  view source on GitHub ↗

CubeTo adds a cubic Bézier path with control points (cpx1,cpy1) and (cpx2,cpy2) and end point (x,y).

(cpx1, cpy1, cpx2, cpy2, x, y float64)

Source from the content-addressed store, hash-verified

471
472// CubeTo adds a cubic Bézier path with control points (cpx1,cpy1) and (cpx2,cpy2) and end point (x,y).
473func (p *Path) CubeTo(cpx1, cpy1, cpx2, cpy2, x, y float64) {
474 start := p.Pos()
475 cp1 := Point{cpx1, cpy1}
476 cp2 := Point{cpx2, cpy2}
477 end := Point{x, y}
478 if start.Equals(end) && start.Equals(cp1) && start.Equals(cp2) {
479 return
480 } else if !start.Equals(end) && (start.Equals(cp1) || end.Equals(cp1) || angleEqual(end.Sub(start).AngleBetween(cp1.Sub(start)), 0.0) && angleEqual(end.Sub(start).AngleBetween(end.Sub(cp1)), 0.0)) && (start.Equals(cp2) || end.Equals(cp2) || angleEqual(end.Sub(start).AngleBetween(cp2.Sub(start)), 0.0) && angleEqual(end.Sub(start).AngleBetween(end.Sub(cp2)), 0.0)) {
481 p.LineTo(end.X, end.Y)
482 return
483 }
484
485 if len(p.d) == 0 {
486 p.MoveTo(0.0, 0.0)
487 } else if p.d[len(p.d)-1] == CloseCmd {
488 p.MoveTo(p.d[len(p.d)-3], p.d[len(p.d)-2])
489 }
490 p.d = append(p.d, CubeToCmd, cp1.X, cp1.Y, cp2.X, cp2.Y, end.X, end.Y, CubeToCmd)
491}
492
493// ArcTo adds an arc with radii rx and ry, with rot the counter clockwise rotation with respect to the coordinate system in degrees, large and sweep booleans (see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Arcs), and (x,y) the end position of the pen. The start position of the pen was given by a previous command's end point.
494func (p *Path) ArcTo(rx, ry, rot float64, large, sweep bool, x, y float64) {

Callers 10

PathMethod · 0.95
PathMethod · 0.95
JoinMethod · 0.95
SplitAtMethod · 0.95
ParseSVGPathFunction · 0.95
arcToCubeFunction · 0.95
xmonotoneCubicBezierFunction · 0.95
SmoothenMethod · 0.95
renderPathMethod · 0.95
addPathMethod · 0.45

Calls 8

PosMethod · 0.95
EqualsMethod · 0.95
SubMethod · 0.95
LineToMethod · 0.95
MoveToMethod · 0.95
angleEqualFunction · 0.85
AngleBetweenMethod · 0.80
EqualsMethod · 0.45

Tested by

no test coverage detected