Add vector overloads of arc and arcTo.
This commit is contained in:
parent
bd46136952
commit
48694ad735
2 changed files with 16 additions and 0 deletions
|
@ -636,6 +636,14 @@ proc arc*(ctx: Context, x, y, r, a0, a1: float32, ccw: bool = false) =
|
|||
## Draws a circular arc.
|
||||
ctx.path.arc(x, y, r, a0, a1, ccw)
|
||||
|
||||
proc arc*(ctx: Context, pos: Vec2, r: float32, a: Vec2, ccw: bool = false) =
|
||||
## Adds a circular arc to the current sub-path.
|
||||
ctx.path.arc(pos, r, a, ccw)
|
||||
|
||||
proc arcTo*(ctx: Context, x1, y1, x2, y2, radius: float32) =
|
||||
## Draws a circular arc using the given control points and radius.
|
||||
ctx.path.arcTo(x1, y1, x2, y2, radius)
|
||||
|
||||
proc arcTo*(ctx: Context, a, b: Vec2, r: float32) =
|
||||
## Adds a circular arc using the given control points and radius.
|
||||
ctx.path.arcTo(a, b, r)
|
||||
|
|
|
@ -437,6 +437,10 @@ proc arc*(path: var Path, x, y, r, a0, a1: float32, ccw: bool) =
|
|||
path.at.y = y + r * sin(a1)
|
||||
path.ellipticalArcTo(r, r, 0, angle >= PI, cw, path.at.x, path.at.y)
|
||||
|
||||
proc arc*(path: var Path, pos: Vec2, r: float32, a: Vec2, ccw: bool = false) =
|
||||
## Adds a circular arc to the current sub-path.
|
||||
path.arc(pos.x, pos.y, r, a.x, a.y, ccw)
|
||||
|
||||
proc arcTo*(path: var Path, x1, y1, x2, y2, r: float32) =
|
||||
## Adds a circular arc using the given control points and radius.
|
||||
## Commonly used for making rounded corners.
|
||||
|
@ -478,6 +482,10 @@ proc arcTo*(path: var Path, x1, y1, x2, y2, r: float32) =
|
|||
path.at.y = y1 + t21 * y21
|
||||
path.ellipticalArcTo(r, r, 0, false, y01 * x20 > x01 * y20, path.at.x, path.at.y)
|
||||
|
||||
proc arcTo*(path: var Path, a, b: Vec2, r: float32) =
|
||||
## Adds a circular arc using the given control points and radius.
|
||||
path.arcTo(a.x, a.y, b.x, b.y, r)
|
||||
|
||||
proc rect*(path: var Path, x, y, w, h: float32, clockwise = true) =
|
||||
## Adds a rectangle.
|
||||
## Clockwise param can be used to subtract a rect from a path when using
|
||||
|
|
Loading…
Reference in a new issue