アットウィキロゴ

gunbbh

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 
<script>
 
var ball=new Array();
var bx=new Array();
var by=new Array();
 
function sample(){
 
gun=250; 
 
for(s=1;s<101;s++){ 
bx[s]=0;
by[s]=500;
ball[s]=0;
}
 
var timer;
var delay = 100;
 
var loop = function () {
 
sx=0;
for(s=1;s<101;s++){
if(ball[s]<50)sx=s;
}
 
dx=10;
if(Math.random()>0.5)dx=-10;
gun=gun+dx;
 
if(gun>500)gun=500;
if(gun<0)gun=0;
 
 
if(Math.random()>0.5){
ball[sx]=100;
bx[sx]=gun;
by[sx]=500;
}
 
 
for(s=1;s<101;s++){
by[s]=by[s]-10;
if(by[s]<20)ball[s]=0;
}
 
 
 
paint();
 
 
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
}
 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">"; 
str=str+sub.rect(0,0,500,500,"blue");
for(s=1;s<101;s++){
if(ball[s]>50)str=str+sub.circle(bx[s],by[s],5,"red");
}
str=str+"</svg>";
 
$("#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日 21:46