var x=new Array();
var a=new Array();
var mode;
function sample(){
for(s=1;s<41;s++){
x[s]=0;
}
a[1]=1;
a[2]=1;
a[3]=1;
a[4]=1;
mode=4;
var timer;
var delay = 100;
var loop = function () {
mode=mode+1;
if(mode>4)mode=1;
a[mode]=a[mode]+dice();
if(a[mode]>40)a[mode]=a[mode]-40;
n=a[mode];
if(x[n]==0)x[n]=mode;
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function dice(){
n1=6*Math.random();
n2=Math.floor(n1)+1;
n1=6*Math.random();
n2=n2+Math.floor(n1)+1;
return n2;
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"700\" height=\"700\">";
str=str+sub.rect(10,10*a[1],10,10,"blue");
str=str+sub.rect(50,10*a[2],10,10,"green");
str=str+sub.rect(150,10*a[3],10,10,"red");
str=str+sub.rect(200,10*a[4],10,10,"pink");
for(s=1;s<41;s++){
if(x[s]==1)str=str+sub.rect(300,10*s,100,10,"blue");
if(x[s]==2)str=str+sub.rect(300,10*s,100,10,"green");
if(x[s]==3)str=str+sub.rect(300,10*s,100,10,"red");
if(x[s]==4)str=str+sub.rect(300,10*s,100,10,"pink");
}
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2016年04月17日 19:46