//InitGraph(); rows=31;cols=47; ScaleWindow(0, 0,cols+1, rows+1) Colour(Black); BoxFill(0,0,cols+1,rows+1); pic1=new Array(cols);pic2=new Array(cols); for(var i = 0;i<=cols;i++){ pic1[i]=new Array(rows);pic2[i]=new Array(rows); } function showpic2() { //and copy pic2 to pic1 for(var i = 0;i<=cols;i++){ for(var j = 0;j<=rows;j++) { m=5*pic2[i][j] ColourRGB(m,m,m); BoxFill(i, j, 1.1, 1.1); Colour(Red); pic1[i][j]=pic2[i][j]; } } } //Set up picture - a noisy ball Colour("silver"); m=(rows+cols)/2; for (i = 0;i<= cols;i++){ for (j = 0; j<=rows;j++) { k = m - Math.abs(i - cols/2) - Math.abs(j - rows/2); k = k + 12. * Math.random(); pic1 [i][j] = k; c = 5 * k; ColourRGB(c, c, c); BoxFill(i, j, 1, 1); } } phase=0; i=0; j=0; step=1; b = 6.; //sets the 'blur' constant a=pic1[0][0]; setTimeout('eval(document.panels.prog.value);',10);
switch(phase){ case 0: //blur horizontally a = a + (pic1[i][j] - a) / b; pic1 [i][j] = a; c=6*a; ColourRGB(c,c,c); BoxFill(i, j, 1, 1); i+=step; if(i>cols){ i=cols; step=-1; } if(i<0){ i=0; j+=1; step=1; } if(j>rows){ phase=1; i=0; j=0; a=pic1[0][0]; } break; case 1: //blur vertically a = a + (pic1[i][j] - a) / b; pic1 [i][j] = a; c=6*a; ColourRGB(c,c,c); BoxFill(i, j, 1, 1); j+=step; if(j>rows){ j=rows; step=-1; } if(j<0){ j=0; i+=1; step=1; } break; } if(i<=cols){ // not all done setTimeout('eval(document.panels.prog.value);',5); }