commit
e0ab3829b1
4 changed files with 19 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
version = "4.0.1"
|
||||
version = "4.0.2"
|
||||
author = "Andre von Houck and Ryan Oldenburg"
|
||||
description = "Full-featured 2d graphics library for Nim."
|
||||
license = "MIT"
|
||||
|
|
|
@ -669,13 +669,13 @@ proc circle*(ctx: Context, circle: Circle) {.inline, raises: [].} =
|
|||
|
||||
proc polygon*(
|
||||
ctx: Context, x, y, size: float32, sides: int
|
||||
) {.inline, raises: [].} =
|
||||
) {.inline, raises: [PixieError].} =
|
||||
## Adds an n-sided regular polygon at (x, y) of size to the current path.
|
||||
ctx.path.polygon(x, y, size, sides)
|
||||
|
||||
proc polygon*(
|
||||
ctx: Context, pos: Vec2, size: float32, sides: int
|
||||
) {.inline, raises: [].} =
|
||||
) {.inline, raises: [PixieError].} =
|
||||
## Adds an n-sided regular polygon at (x, y) of size to the current path.
|
||||
ctx.path.polygon(pos, size, sides)
|
||||
|
||||
|
|
|
@ -628,8 +628,12 @@ proc circle*(path: Path, circle: Circle) {.inline, raises: [].} =
|
|||
## Adds a circle.
|
||||
path.ellipse(circle.pos.x, circle.pos.y, circle.radius, circle.radius)
|
||||
|
||||
proc polygon*(path: Path, x, y, size: float32, sides: int) {.raises: [].} =
|
||||
proc polygon*(
|
||||
path: Path, x, y, size: float32, sides: int
|
||||
) {.raises: [PixieError].} =
|
||||
## Adds an n-sided regular polygon at (x, y) with the parameter size.
|
||||
if sides <= 0:
|
||||
raise newException(PixieError, "Invalid polygon sides value")
|
||||
path.moveTo(x + size * cos(0.0), y + size * sin(0.0))
|
||||
for side in 0 .. sides:
|
||||
path.lineTo(
|
||||
|
@ -639,7 +643,7 @@ proc polygon*(path: Path, x, y, size: float32, sides: int) {.raises: [].} =
|
|||
|
||||
proc polygon*(
|
||||
path: Path, pos: Vec2, size: float32, sides: int
|
||||
) {.inline, raises: [].} =
|
||||
) {.inline, raises: [PixieError].} =
|
||||
## Adds a n-sided regular polygon at (x, y) with the parameter size.
|
||||
path.polygon(pos.x, pos.y, size, sides)
|
||||
|
||||
|
|
|
@ -665,3 +665,13 @@ block:
|
|||
color = rgba(255, 0, 0, 255)
|
||||
image.fillPath(pathStr, color)
|
||||
image.writeFile("tests/paths/path0pxCover.png")
|
||||
|
||||
block:
|
||||
let image = newImage(200, 200)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
|
||||
let ctx = newContext(image)
|
||||
ctx.setLineDash(@[2.0.float32])
|
||||
|
||||
doAssertRaises PixieError:
|
||||
ctx.strokePolygon(vec2(0.0, 0.0), 0.0, 0)
|
||||
|
|
Loading…
Reference in a new issue