<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function sample(){
var timer;
var delay = 100;
x=0;
var loop = function () {
x=x+10;
y=x;
if(x>490)x=0;
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
str=str+sub.line(x,y,500,500,4,"green");
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月16日 00:57