var x=new Array();
var y=new Array();
var point=new Array();
var a,b,c,d;
function sample(){
tx=0;
for(s=1;s<9;s++){
for(sx=1;sx<6;sx++){
tx=tx+1;
y[tx]=s;
x[tx]=sx;
point[tx]=0;
}
}
a=1;
b=1;
c=1;
d=1;
mode=4;
var timer;
var delay = 1000;
var loop = function () {
mode=mode+1;
if(mode>4)mode=1;
n1=6*Math.random();
n2=Math.floor(n1)+1;
n1=6*Math.random();
m2=Math.floor(n1)+1;
if(mode==1)a=a+n2+m2;
if(mode==2)b=b+n2+m2;
if(mode==3)c=d+n2+m2;
if(mode==4)d=d+n2+m2;
if(a>40)a=a-40;
if(b>40)b=b-40;
if(c>40)c=c-40;
if(d>40)d=d-40;
k=0;
if(mode==1)k=a;
if(mode==2)k=b;
if(mode==3)k=c;
if(mode==4)k=d;
if(point[k]==0)point[k]=mode;
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
paint();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
for(s=1;s<41;s++){
str=str+sub.rect(100*x[s]-100,500-50*y[s],100,50,"purple");
}
for(s=1;s<41;s++){
if(point[s]==1)str=str+sub.rect(100*x[s]-100,500-50*y[s],100,50,"green");
if(point[s]==2)str=str+sub.rect(100*x[s]-100,500-50*y[s],100,50,"blue");
if(point[s]==3)str=str+sub.rect(100*x[s]-100,500-50*y[s],100,50,"red");
if(point[s]==4)str=str+sub.rect(100*x[s]-100,500-50*y[s],100,50,"yellow");
}
str=str+sub.rect(100*x[a]-100,500-50*y[a],100,50,"green");
str=str+sub.rect(100*x[b]-100,500-50*y[b],100,50,"blue");
str=str+sub.rect(100*x[c]-100,500-50*y[c],100,50,"red");
str=str+sub.rect(100*x[d]-100,500-50*y[d],100,50,"yellow");
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2016年01月04日 19:38