InitGraph(); rows=31;cols=31; 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); } filt=new Array(3); filt[0]=new Array( 0,-1, 0); filt[1]=new Array(-1, 4,-1); filt[2]=new Array( 0,-1, 0); window.showpic1=function() { //and copy to pic1 for(var i = 0;i<=cols;i++){ for(var j = 0;j<=rows;j++) { if (pic1[i][j]>0){ Colour(Red)}else{Colour(Black)}; BoxFill(i, j,.8, .8); // pic1[i][j]=pic2[i][j]; } } } window.showpic2=function() { //and copy to pic1 for(var i = 0;i<=cols;i++){ for(var j = 0;j<=rows;j++) { if (pic2[i][j]>0){ Colour(Red)}else{Colour(Black)}; BoxFill(i, j,.8, .8); pic1[i][j]=pic2[i][j]; } } } function smooth() { for(var i = 1;i
4) { //If majority are set pic2 [i][j] = 1; //set pixel of pic2 to red }else{ pic2 [i][j] = 0; //set pixel of pic2 to black }; Colour(White); Label(m,i,j); //show count } } } function filter() { Colour("yellow"); for(var i = 1;i
=1) { //If total is positive pic2 [i][j] = 1; //set pixel of pic2 to red }else{ pic2 [i][j] = 0; //set pixel of pic2 to black }; Label(m,i,j); } } } //Set up picture with a ragged diamond for (i = 0;i<= cols;i++){ for (j = 0; j<=rows;j++) { k = Math.abs(i - rows/2) + Math.abs(j - cols/2); if (k + 6 * Math.random() < 14) { pic2[i][j] = 1;} else { pic2 [i][j] = 0; }; } } showpic2(); n=0; setTimeout('eval(document.panels.step.value);',3000);
switch(n){ case 0: smooth(); break; case 1: showpic2(); break; case 2: filter(); break; case 3: showpic2(); } n++; if(n<4){ setTimeout('eval(document.panels.step.value);',2000); }