Open
Description
For projection mapping to cutting area. Based on 23"x35" standard cutting mat, with 72ppi.
# Cutting mat registration image
canvas = document.createElement 'canvas'
context = canvas.getContext '2d'
document.body.appendChild canvas
scale = 72
scaleHalf = scale/2
width = 35*scale
canvas.width = width+5
height = 23*scale
canvas.height = height+5
# Offset for whole pixels
context.translate 3+0.5, 3+0.5
bg = 'transparent'
context.fillStyle = bg
context.fillRect 0, 0, width, height
segment = (x1, y1, x2, y2) ->
context.beginPath()
context.moveTo x1, y1
context.lineTo x2, y2
context.stroke()
draw = ->
x = 0
while x <= width
segment x, 0, x, height
x += scale
y = 0
while y <= height
segment 0, y, width, y
y += scale
# Subgrid
x = scale+scaleHalf
while x < width-scale
segment x, scale, x, height-scale
x += scale
y = scale+scaleHalf
while y < height-scale
segment scale, y, width-scale, y
y += scale
# Diagonal lines
#45
segment 0, height, height, 0
#90
segment height/2, height/2, height, height
#60
segment 0, height, height*Math.tan(Math.PI*1/6), 0
#30
segment 0, height, height*Math.tan(Math.PI*1/3), 0
# Eighth inch marks
x = 0
while x <= width
segment x, 0, x, scale/8
segment x, height, x, height-scale/8
x += scale/8
y = 0
while y <= height
segment 0, y, scale/8, y
segment width, y, width-scale/8, y
y += scale/8
context.strokeStyle = 'black'
context.lineWidth = 3
draw()
context.strokeStyle = 'white'
context.lineWidth = 1
draw()
Metadata
Metadata
Assignees
Labels
No labels
Activity