Skip to content
Snippets Groups Projects
Commit cebddea1 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

path rastering

parent 5ab55ea9
No related branches found
No related tags found
No related merge requests found
......@@ -227,26 +227,50 @@ function calculate_path() {
//
// line loop
//
var step = 1
var ix = 0
var iy = 10
var x1 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
var y1 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
var iy = mod.height-1
var dx = 1
var dy = 0
//var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
//var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
while (1) {
ix += step
if (ix == mod.width)
break;
var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
var ixp = ix
var iyp = iy
ix += dx
iy += dy
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
line.setAttribute('x1',x1)
line.setAttribute('y1',y1)
line.setAttribute('x2',x2)
line.setAttribute('y2',y2)
line.setAttribute('x1',ixp)
line.setAttribute('y1',iyp)
line.setAttribute('x2',ix)
line.setAttribute('y2',iy)
g.appendChild(line)
//var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
//var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
if (iy <= 0)
break;
if (ix == (mod.width-1)) {
if (dx == 1) {
dx = 0
dy = -10
}
else {
dx = -1
dy = 0
}
}
else if (ix == 0) {
if (dx == -1) {
dx = 0
dy = -10
}
else {
dx = 1
dy = 0
}
}
}
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment