yes i do it :)
dcangle = (ctadegree0360+90)*pi/180/(nangle-2);
//dcangle = cta/(n-2);
// px[0] and px[0] define the centre of polygon
px[0]=x0; // for drawing angle polygon
py[0]=y0; //
// if statement to draw polygon angle
for(int i=1;i<nangle;i++){
//  c=Math.atan2(y,x)-(i-1)*dcangle;  // modify to work drawing from black line
//  c=(Math.atan2(y,x))-(i-1)*dcangle;
c = (ctadegree0360+90)*pi/180-(i-1)*dcangle;

// if(c>pi)c-=2*pi; // to overcome pi to -pi problem
// if(c<-pi)c+=2*pi;
// else if (c>pi) c-=2*pi;
px[i]=x0+d*Math.cos(c); //
py[i]=y0+d*Math.sin(c); //
}

i am getting better at ejs :)