From 3387ff3b8f61da032a2707987e496f47e058227c Mon Sep 17 00:00:00 2001 From: jiyinyiyong Date: Mon, 23 Nov 2020 16:31:33 +0800 Subject: [PATCH] fix error in arc op; bump 0.0.18 --- README.md | 7 ++++--- json_paint.nimble | 2 +- src/json_paint/shape_renderer.nim | 4 ++-- tests/demo.nim | 8 ++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e6f0b9..d0c2880 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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] @@ -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]], diff --git a/json_paint.nimble b/json_paint.nimble index c28872a..4f49712 100644 --- a/json_paint.nimble +++ b/json_paint.nimble @@ -1,6 +1,6 @@ # Package -version = "0.0.17" +version = "0.0.18" author = "jiyinyiyong" description = "JSON DSL for canvas rendering" license = "MIT" diff --git a/src/json_paint/shape_renderer.nim b/src/json_paint/shape_renderer.nim index a9cf495..a986605 100644 --- a/src/json_paint/shape_renderer.nim +++ b/src/json_paint/shape_renderer.nim @@ -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 @@ -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) diff --git a/tests/demo.nim b/tests/demo.nim index 4505627..c450a30 100644 --- a/tests/demo.nim +++ b/tests/demo.nim @@ -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"], + ] + }, ] })