Added pos guide draw
This commit is contained in:
parent
af4d294d2c
commit
bf7dbedb23
@ -85,6 +85,9 @@ function Surface (ronin) {
|
|||||||
if (isLine(shape)) {
|
if (isLine(shape)) {
|
||||||
this.traceLine(shape, context)
|
this.traceLine(shape, context)
|
||||||
}
|
}
|
||||||
|
if (isPos(shape)) {
|
||||||
|
this.tracePos(shape, context)
|
||||||
|
}
|
||||||
if (isCircle(shape)) {
|
if (isCircle(shape)) {
|
||||||
this.traceCircle(shape, context)
|
this.traceCircle(shape, context)
|
||||||
} else if (isText(shape)) {
|
} else if (isText(shape)) {
|
||||||
@ -107,6 +110,14 @@ function Surface (ronin) {
|
|||||||
context.lineTo(line.b.x, line.b.y)
|
context.lineTo(line.b.x, line.b.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.tracePos = function (pos, context, radius = 7.5) {
|
||||||
|
context.lineCap = 'round'
|
||||||
|
context.moveTo(pos.x - radius, pos.y)
|
||||||
|
context.lineTo(pos.x + radius, pos.y)
|
||||||
|
context.moveTo(pos.x, pos.y - radius)
|
||||||
|
context.lineTo(pos.x, pos.y + radius)
|
||||||
|
}
|
||||||
|
|
||||||
this.traceCircle = function (circle, context) {
|
this.traceCircle = function (circle, context) {
|
||||||
context.arc(circle.cx, circle.cy, circle.r, 0, 2 * Math.PI)
|
context.arc(circle.cx, circle.cy, circle.r, 0, 2 * Math.PI)
|
||||||
}
|
}
|
||||||
@ -169,10 +180,12 @@ function Surface (ronin) {
|
|||||||
|
|
||||||
this.drawGuide = function (shape, color = 'white', context = this.guide) {
|
this.drawGuide = function (shape, color = 'white', context = this.guide) {
|
||||||
if (!shape) { return }
|
if (!shape) { return }
|
||||||
this.stroke(shape.rect || shape, 3, 'black', context)
|
this.stroke(shape.rect || shape, 4, 'black', context)
|
||||||
if (shape.line) { this.stroke(shape.line, 3, 'black', context) }
|
if (shape.pos) { this.stroke(shape.pos, 4, 'black', context) }
|
||||||
if (shape.circle) { this.stroke(shape.circle, 3, 'black', context) }
|
if (shape.line) { this.stroke(shape.line, 4, 'black', context) }
|
||||||
|
if (shape.circle) { this.stroke(shape.circle, 4, 'black', context) }
|
||||||
this.stroke(shape.rect || shape, 1.5, color, context)
|
this.stroke(shape.rect || shape, 1.5, color, context)
|
||||||
|
if (shape.pos) { this.stroke(shape.pos, 1.5, color, context) }
|
||||||
if (shape.line) { this.stroke(shape.line, 1.5, color, context) }
|
if (shape.line) { this.stroke(shape.line, 1.5, color, context) }
|
||||||
if (shape.circle) { this.stroke(shape.circle, 1.5, color, context) }
|
if (shape.circle) { this.stroke(shape.circle, 1.5, color, context) }
|
||||||
}
|
}
|
||||||
@ -266,6 +279,9 @@ function Surface (ronin) {
|
|||||||
function isCircle (shape) {
|
function isCircle (shape) {
|
||||||
return !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.r)
|
return !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.r)
|
||||||
}
|
}
|
||||||
|
function isPos (shape) {
|
||||||
|
return !isNaN(shape.x) && !isNaN(shape.y)
|
||||||
|
}
|
||||||
function isSvg (shape) {
|
function isSvg (shape) {
|
||||||
return shape.d
|
return shape.d
|
||||||
}
|
}
|
||||||
|
46
examples/tools/guides.lisp
Normal file
46
examples/tools/guides.lisp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
(clear)
|
||||||
|
; guides
|
||||||
|
(fill (frame) "white")
|
||||||
|
(def frame-rect (frame))
|
||||||
|
(defn draw-cross
|
||||||
|
(pos)
|
||||||
|
(guide {:x (floor pos:x) :y (floor pos:y)}))
|
||||||
|
; top
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.25)
|
||||||
|
(mul frame-rect:h 0.25)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.5)
|
||||||
|
(mul frame-rect:h 0.25)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.75)
|
||||||
|
(mul frame-rect:h 0.25)))
|
||||||
|
; middle
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.25)
|
||||||
|
(mul frame-rect:h 0.5)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.5)
|
||||||
|
(mul frame-rect:h 0.5)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.75)
|
||||||
|
(mul frame-rect:h 0.5)))
|
||||||
|
; bottom
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.25)
|
||||||
|
(mul frame-rect:h 0.75)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.5)
|
||||||
|
(mul frame-rect:h 0.75)))
|
||||||
|
(draw-cross
|
||||||
|
(pos
|
||||||
|
(mul frame-rect:w 0.75)
|
||||||
|
(mul frame-rect:h 0.75)))
|
Loading…
x
Reference in New Issue
Block a user