var context=("my_canvas");
context=("2d");
var circles=[];
var width=500;
var height=400;
var max_radius=30;
var min_radius=20;
var count=0;
=function(){
var btn=("my_btn");
=function(){
var time=new Date();
start=();
make_circle();
}
}
function Circle(x,y,r,color){
=x;
=y;
=r;
=color;
}
function make_circle(){
var x=(()*width)+1;
var y=(()*height)+1;
var r=(()*(max_radius-min_radius))+min_radius;
var color="rgb("+((()*256))+","+((()*256))+","+((()*256))+")";//make different color
var circle=new Circle(x,y,r,color);
if(test1(circle)&&test2(circle)){
(circle);
=color;
();
(x,y,r,0,*2,true);
();
();
count=0;
}
else{
count++;
if(count>10000){//if it loops too many times,we can assume that there is no space for new circle
alert("no more circle");
return false;
}
make_circle();
}
}
function test1(circle){//test if the new circle intersects with the others
var len=;
for(var i=0;i<len;i++){
var x1=circles[i].x;
var y1=circles[i].y;
var r1=circles[i].r;
var x2=;
var y2=;
var r2=;
if((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<(r2+r1)*(r2+r1)){
return false;
}
}
return true;
}
function test2(circle){//test if the new circle touchs the border
if((+)>width||(+)>height||()<0||()<0){
return false;
}
else{
return true;
}
}