<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var number_pol;
var x_pol=new Array();
var y_pol=new Array();
function sample() {
number_pol=3;
x_pol[1]=0;
y_pol[1]=0;
x_pol[2]=200;
y_pol[2]=0;
x_pol[3]=0;
y_pol[3]=200;
paint();
}
function paint(){
var sub=new polygon();
str="<svg width=\"500\" height=\"500\">";
sub.number_pol=number_pol;
sub.x_pol=x_pol;
sub.y_pol=y_pol;
str=str+sub.poly("green");
number_pol=4;
x_pol[1]=200;
y_pol[1]=0;
x_pol[2]=400;
y_pol[2]=0;
x_pol[3]=400;
y_pol[3]=200;
x_pol[4]=200;
y_pol[4]=200;
sub.number_pol=number_pol;
sub.x_pol=x_pol;
sub.y_pol=y_pol;
str=str+sub.poly("blue");
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>
<script>
class polygon{
poly(col){
this.data="";
for(this.s=1;this.s<this.number_pol;this.s++){
this.data=this.data+this.x_pol[this.s]+","+this.y_pol[this.s]+",";
}
this.s=this.number_pol;
this.data=this.data+this.x_pol[this.s]+","+this.y_pol[this.s];
this.str="<polygon fill="+this.chopx(col)+" points="+this.chopx(this.data)+"/>";
return this.str;
}
chopx(strp){
this.strp2="\""+strp+"\"";
return this.strp2;
}
}
</script>
最終更新:2018年06月23日 06:45