diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index a25a14e..a77c90d 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -85,6 +85,9 @@ function Surface (ronin) { if (isLine(shape)) { this.traceLine(shape, context) } + if (isPos(shape)) { + this.tracePos(shape, context) + } if (isCircle(shape)) { this.traceCircle(shape, context) } else if (isText(shape)) { @@ -107,6 +110,14 @@ function Surface (ronin) { 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) { 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) { if (!shape) { return } - this.stroke(shape.rect || shape, 3, 'black', context) - if (shape.line) { this.stroke(shape.line, 3, 'black', context) } - if (shape.circle) { this.stroke(shape.circle, 3, 'black', context) } + this.stroke(shape.rect || shape, 4, 'black', context) + if (shape.pos) { this.stroke(shape.pos, 4, '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) + if (shape.pos) { this.stroke(shape.pos, 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) } } @@ -266,6 +279,9 @@ function Surface (ronin) { function isCircle (shape) { return !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.r) } + function isPos (shape) { + return !isNaN(shape.x) && !isNaN(shape.y) + } function isSvg (shape) { return shape.d } diff --git a/examples/tools/guides.lisp b/examples/tools/guides.lisp new file mode 100644 index 0000000..d9b7396 --- /dev/null +++ b/examples/tools/guides.lisp @@ -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))) \ No newline at end of file