<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var point=new Array();
var pointx=new Array();
function sample(){
var timer;
var delay = 100;
point[0]=0;
pointx[0]=0;
number=0;
var loop = function () {
number=number+1;
if(number>500)number=1;
n1=3*Math.random();
x=Math.floor(n1)+1;
n1=3*Math.random();
y=Math.floor(n1)+1;
var ch=new Array();
var chx=new Array();
sx=0;
for(s=1;s<4;s++){
h=0;
if(y==s)h=100;
if(s==x)h=100;
if(h<50)sx=sx+1;
if(h<50)ch[sx]=s;
}
n1=sx*Math.random();
z1=Math.floor(n1)+1;
z=ch[z1];
q=0;
for(s=1;s<4;s++){
h=0;
if(z==s)h=100;
if(y==s)h=100;
if(h<50)q=s;
}
point[number]=point[number-1];
pointx[number]=pointx[number-1];
if(x==y)point[number]=point[number]+1;
if(x==q)pointx[number]=pointx[number]+1;
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
for(s=1;s<number;s++){
str=str+sub.line(s,500-point[s],s+1,500-point[s+1],3,"red");
str=str+sub.line(s,500-pointx[s],s+1,500-pointx[s+1],3,"blue");
}
str=str+sub.line(0,0,0,500,5,"black");
str=str+sub.line(500,500,0,500,5,"black");
$("#memo").html(str);
}
</script>
<script>
class svgpaint{
chop(strp){
this.strx="\""+strp+"\"";
return this.strx;
}
rect(x1,y1,w1,h1,col){
this.strx="<rect x="+this.chop(x1)+"\" y="+this.chop(y1)+"\" width="+this.chop(w1);
this.strx=this.strx+"\" height="+this.chop(h1)+" fill="+this.chop(col)+"/>";
return this.strx;
}
text(x1,y1,size,strp){
this.strx="<text x="+this.chop(x1)+" y= "+this.chop(y1)+" font-size="+this.chop(size)+">";
this.strx=this.strx+strp;
this.strx=this.strx+"</text>";
return this.strx;
}
circle(x1,y1,r,col){
this.strx="<circle cx="+this.chop(x1)+"\" cy="+this.chop(y1)+"\" r="+this.chop(r)+" fill="+this.chop(col)+"/>";
return this.strx;
}
line(x1,y1,x2,y2,wide,col){
this.strx="<line x1="+this.chop(x1)+" y1="+this.chop(y1)+" x2="+this.chop(x2)+" y2=";
this.strx=this.strx+this.chop(y2)+"style= \" stroke:"+col+";stroke-width:"+wide+"\"/>";
return this.strx;
}
}
</script>
最終更新:2018年06月17日 04:27