Arc adds an elliptical arc with radii rx and ry, with rot the counter clockwise rotation in degrees, and theta0 and theta1 the angles in degrees of the ellipse (before rot is applies) between which the arc will run. If theta0 < theta1, the arc will run in a CCW direction. If the difference between t
(rx, ry, rot, theta0, theta1 float64)
| 533 | |
| 534 | // Arc adds an elliptical arc with radii rx and ry, with rot the counter clockwise rotation in degrees, and theta0 and theta1 the angles in degrees of the ellipse (before rot is applies) between which the arc will run. If theta0 < theta1, the arc will run in a CCW direction. If the difference between theta0 and theta1 is bigger than 360 degrees, one full circle will be drawn and the remaining part of diff % 360, e.g. a difference of 810 degrees will draw one full circle and an arc over 90 degrees. |
| 535 | func (p *Path) Arc(rx, ry, rot, theta0, theta1 float64) { |
| 536 | phi := rot * math.Pi / 180.0 |
| 537 | theta0 *= math.Pi / 180.0 |
| 538 | theta1 *= math.Pi / 180.0 |
| 539 | dtheta := math.Abs(theta1 - theta0) |
| 540 | |
| 541 | sweep := theta0 < theta1 |
| 542 | large := math.Mod(dtheta, 2.0*math.Pi) > math.Pi |
| 543 | p0 := EllipsePos(rx, ry, phi, 0.0, 0.0, theta0) |
| 544 | p1 := EllipsePos(rx, ry, phi, 0.0, 0.0, theta1) |
| 545 | |
| 546 | start := p.Pos() |
| 547 | center := start.Sub(p0) |
| 548 | if dtheta >= 2.0*math.Pi { |
| 549 | startOpposite := center.Sub(p0) |
| 550 | p.ArcTo(rx, ry, rot, large, sweep, startOpposite.X, startOpposite.Y) |
| 551 | p.ArcTo(rx, ry, rot, large, sweep, start.X, start.Y) |
| 552 | if Equal(math.Mod(dtheta, 2.0*math.Pi), 0.0) { |
| 553 | return |
| 554 | } |
| 555 | } |
| 556 | end := center.Add(p1) |
| 557 | p.ArcTo(rx, ry, rot, large, sweep, end.X, end.Y) |
| 558 | } |
| 559 | |
| 560 | // Close closes a (sub)path with a LineTo to the start of the path (the most recent MoveTo command). It also signals the path closes as opposed to being just a LineTo command, which can be significant for stroking purposes for example. |
| 561 | func (p *Path) Close() { |