アットウィキロゴ

reftyy

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 
<script>
 
function sample() {
 
m=1; 
 
 $("#memo").click(function (e) {
 
x1=e.offsetX; 
y1=e.offsetY; 
if(x1<100)m=1;
if(x1>100)m=2;
 
 
 
paint(); 
 
  });   
 
 
paint();
 
 
}
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
if(m==1)str=str+sub.rect(0,0,200,200,"blue");       
if(m==2)str=str+sub.rect(0,0,200,200,"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年07月05日 13:27