Added (svg) type

This commit is contained in:
Devine Lu Linvega 2019-07-15 08:28:23 +09:00
parent 04250e6f84
commit 89196fd28d
3 changed files with 21 additions and 0 deletions

View File

@ -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 }
}

View File

@ -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) {

3
examples/svg.lisp Normal file
View File

@ -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")