Skip to content

Commit

Permalink
fix error in arc op; bump 0.0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Nov 23, 2020
1 parent 6f4c88e commit 3387ff3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Usage

```nim
requires "https://github.com/Quamolit/json-paint.nim#v0.0.17"
requires "https://github.com/Quamolit/json-paint.nim#v0.0.18"
```

```nim
Expand Down Expand Up @@ -41,7 +41,7 @@ Find example in [`tests/demo.nim`](tests/demo.nim).

JSON described in CoffeeScript.

This library uses hsl colors:
This library uses HSL/HSLA colors:

```coffee
[359,99,99,1]
Expand Down Expand Up @@ -96,7 +96,8 @@ ops: [
['stroke-preserve'],
['fill-preserve'],
['line-width', 1],
['source-rgb', Color],
['source-rgb', Color], # which is actually using HSL colors
['hsl', Color], # alias for 'source-rgb'
['move-to', [1, 1]],
['line-to', [1, 1]],
['relative-line-to', [1, 1]],
Expand Down
2 changes: 1 addition & 1 deletion json_paint.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.0.17"
version = "0.0.18"
author = "jiyinyiyong"
description = "JSON DSL for canvas rendering"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions src/json_paint/shape_renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ proc callOps(ctx: ptr Context, tree: JsonNode, base: TreeContext) =
of "line-width":
if item.elems.len < 2: showError("Expects width at index 1")
ctx.setLineWidth item.elems[1].getFloat
of "source-rgb":
of "source-rgb", "hsl":
if item.elems.len < 2: showError("Expects color at index 1 for source-rgb")
let color = readJsonColor(item.elems[1])
ctx.setSourceRgba color.r, color.g, color.b, color.a
Expand Down Expand Up @@ -207,7 +207,7 @@ proc callOps(ctx: ptr Context, tree: JsonNode, base: TreeContext) =
let radius = item.elems[2].getFloat
let angle = readPointVec item.elems[3] # actuall start-angle/end-angle

let negative = if tree.elems.len >= 5: tree.elems[4].getBool else: false
let negative = if item.elems.len >= 5: item.elems[4].getBool else: false

if negative:
ctx.arcNegative(point.x + base.x, point.y + base.y, radius, angle.x, angle.y)
Expand Down
8 changes: 8 additions & 0 deletions tests/demo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ proc renderSomething() =
"path": ["a", 1],
"action": ":demo",
},
{
"type": "ops",
"ops": [
["arc", [100, 100], 10, [0, 6.2], false],
["source-rgb", [0, 80, 80]],
["fill"],
]
},
]
})

Expand Down

0 comments on commit 3387ff3

Please sign in to comment.