var a, i, x1, y1, length =0; var pi = Math.PI; for (i=0; i != 2 * vertices ; i++){ this.beginPath(); this.moveTo(0,0); a = i * (2 * pi/ (2*vertices) ) + startangle; length = radius - depth * (i % 2); x1 = length * Math.sin(a); y1 = length * Math.cos(a); this.lineTo( x1, y1); a = (i +1)* (2 * pi/ (2*vertices) ) + startangle; length = radius - depth * ((i +1)% 2); x1 = length * Math.sin(a); y1 = length * Math.cos(a); this.lineTo( x1, y1); this.closePath(); this.fillStyle= colors[i % 2]; this.fill(); this.strokeStyle =bordercolors[i % 2]; this.lineWidth = border; this.stroke(); }