/* very simple recursive paths... based on the code developed by By David Betz, at http://www.davidbetz.net/graphics/. */ var dynamicAttacherObj; function draw( ) { dynamicAttacherObj = document.getElementById('DynamicAttacher'); var graphics = new Graphics('Shapes'); try { recursepath( 85,0,0,1, 5, graphics); } catch(ex) { throw ex; } } function recursepath(xpos, ypos, xvec, yvec, recl, gr){ if (recl==0) return; //do a path of n steps for (var i=0;i<17;i++){ if (Math.random()<0.02) return; xvec+=Math.random()-0.5; yvec+=Math.random()-0.2; var dis=xvec*xvec+yvec*yvec; if (dis>4) { dis=Math.sqrt(dis); xvec/=dis; xvec*=2; yvec/=dis; yvec*=2; } if (xpos<10 && xvec<0) //xvec=-xvec; xvec+=0.5; else if (xpos>170 && xvec>0) //xvec=-xvec; xvec-=0.5; if (ypos<0 && yvec<0) yvec=-yvec; else if (ypos>20000 && yvec>0) yvec=-yvec; xpos+=10*xvec; ypos+=10*yvec; gr.Attach(dynamicAttacherObj,gr.drawRect(xpos,ypos,6,14,'rgb(200,200,200)' , 'rgb(170,170,170)', 0, null)); } recursepath(xpos, ypos, xvec, yvec, recl-1, gr) recursepath(xpos, ypos, xvec, yvec, recl-1, gr) } Graphics.prototype.drawRect = function(x1, y1, w, h, c, bc, p, id) { var newBox = document.createElement('div'); newBox.className = 'Ink'; newBox.className = 'Ink Border'; if(bc && bc.length > 0) { newBox.style.borderColor = bc; } newBox.style.zIndex = p; newBox.style.backgroundColor = c; newBox.style.width = w + 'px'; newBox.style.height = h + 'px'; newBox.style.left = x1 + 'px'; newBox.style.top = y1 + 'px'; newBox.id = id; return newBox; } /* Class Graphics */ function Graphics( ) { this.Collection = new Array( ); } Graphics.prototype.Attach = function(parentObj, childObj) { parentObj.appendChild(childObj); }