From 89196fd28dcf070375fc74901df717219e3ec498 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 15 Jul 2019 08:28:23 +0900 Subject: [PATCH] Added (svg) type --- desktop/sources/scripts/library.js | 4 ++++ desktop/sources/scripts/surface.js | 14 ++++++++++++++ examples/svg.lisp | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 examples/svg.lisp diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 50f3944..2345a0c 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -132,6 +132,10 @@ function Library (ronin) { return { a, b, t } } + this.svg = (d, t = 'svg') => { + return { d, t } + } + this.text = (x, y, g, s, f = 'Arial', t = 'text') => { return { x, y, g, s, f, t } } diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index 73e7f53..17d4f44 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -44,6 +44,10 @@ function Surface (ronin) { if (shape.t === 'text') { context.font = `${shape.g}px ${shape.f}` context.strokeText(shape.s, shape.x, shape.y) + } else if (shape.t === 'svg') { + context.lineWidth = width + context.strokeStyle = color + context.stroke(new Path2D(shape.d)) } else { context.stroke() } @@ -59,6 +63,10 @@ function Surface (ronin) { if (shape.t === 'text') { context.font = `${shape.g}px ${shape.f}` context.fillText(shape.s, shape.x, shape.y) + } else if (shape.t === 'svg') { + context.lineWidth = width + context.fillStyle = color + context.fill(new Path2D(shape.d)) } else { context.fill() } @@ -76,6 +84,8 @@ function Surface (ronin) { this.traceCircle(shape, context) } else if (shape.t === 'text') { this.traceText(shape, context) + } else if (shape.t === 'svg') { + this.traceSVG(shape, context) } else { console.warn('Unknown type') } @@ -102,6 +112,10 @@ function Surface (ronin) { } + this.traceSVG = function (text, context) { + + } + // IO this.open = function (path, scale) { diff --git a/examples/svg.lisp b/examples/svg.lisp new file mode 100644 index 0000000..890afb8 --- /dev/null +++ b/examples/svg.lisp @@ -0,0 +1,3 @@ +(stroke + (svg "M255,60 L255,60 L135,180 L75,60 L195,210 L120,225 L105,225 L165,255 L225,195 L255,135 L285,150") + 2 "red") \ No newline at end of file