Added (svg) type
This commit is contained in:
parent
04250e6f84
commit
89196fd28d
@ -132,6 +132,10 @@ function Library (ronin) {
|
|||||||
return { a, b, t }
|
return { a, b, t }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.svg = (d, t = 'svg') => {
|
||||||
|
return { d, t }
|
||||||
|
}
|
||||||
|
|
||||||
this.text = (x, y, g, s, f = 'Arial', t = 'text') => {
|
this.text = (x, y, g, s, f = 'Arial', t = 'text') => {
|
||||||
return { x, y, g, s, f, t }
|
return { x, y, g, s, f, t }
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,10 @@ function Surface (ronin) {
|
|||||||
if (shape.t === 'text') {
|
if (shape.t === 'text') {
|
||||||
context.font = `${shape.g}px ${shape.f}`
|
context.font = `${shape.g}px ${shape.f}`
|
||||||
context.strokeText(shape.s, shape.x, shape.y)
|
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 {
|
} else {
|
||||||
context.stroke()
|
context.stroke()
|
||||||
}
|
}
|
||||||
@ -59,6 +63,10 @@ function Surface (ronin) {
|
|||||||
if (shape.t === 'text') {
|
if (shape.t === 'text') {
|
||||||
context.font = `${shape.g}px ${shape.f}`
|
context.font = `${shape.g}px ${shape.f}`
|
||||||
context.fillText(shape.s, shape.x, shape.y)
|
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 {
|
} else {
|
||||||
context.fill()
|
context.fill()
|
||||||
}
|
}
|
||||||
@ -76,6 +84,8 @@ function Surface (ronin) {
|
|||||||
this.traceCircle(shape, context)
|
this.traceCircle(shape, context)
|
||||||
} else if (shape.t === 'text') {
|
} else if (shape.t === 'text') {
|
||||||
this.traceText(shape, context)
|
this.traceText(shape, context)
|
||||||
|
} else if (shape.t === 'svg') {
|
||||||
|
this.traceSVG(shape, context)
|
||||||
} else {
|
} else {
|
||||||
console.warn('Unknown type')
|
console.warn('Unknown type')
|
||||||
}
|
}
|
||||||
@ -102,6 +112,10 @@ function Surface (ronin) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.traceSVG = function (text, context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
|
|
||||||
this.open = function (path, scale) {
|
this.open = function (path, scale) {
|
||||||
|
3
examples/svg.lisp
Normal file
3
examples/svg.lisp
Normal 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")
|
Loading…
x
Reference in New Issue
Block a user