
  /////////////////////////////
  // 
  //  This code was written as an example code, modify it your needs !
  //  This code is explained in the tutorials over at [http://www.kirupa.com] look for the 'scripting' tutorials
  //  Written by mlk over at www.kirupaforum.com, post over there for help !
  //
  //  [mlkdesign@online.fr]
  //  july 2004
  //

displayDialogs = DialogModes.NO;

function makeCircle(left,top,right,bottom,antiAlias){

var circleSelection = charIDToTypeID( "setd" );
    var descriptor = new ActionDescriptor();
    var id71 = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var id72 = charIDToTypeID( "Chnl" );
        var id73 = charIDToTypeID( "fsel" );
        ref5.putProperty( id72, id73 );
    descriptor.putReference( id71, ref5 );
    var id74 = charIDToTypeID( "T   " );
        var desc12 = new ActionDescriptor();

        var top1 = charIDToTypeID( "Top " );
        var top2 = charIDToTypeID( "#Pxl" );
        desc12.putUnitDouble( top1, top2, top );

        var left1 = charIDToTypeID( "Left" );
        var left2 = charIDToTypeID( "#Pxl" );
        desc12.putUnitDouble( left1, left2, left );

        var bottom1 = charIDToTypeID( "Btom" );
        var bottom2 = charIDToTypeID( "#Pxl" );
        desc12.putUnitDouble( bottom1, bottom2, bottom );

        var right1 = charIDToTypeID( "Rght" );
        var right2 = charIDToTypeID( "#Pxl" );
        desc12.putUnitDouble( right1, right2, right );

    var id83 = charIDToTypeID( "Elps" );
    descriptor.putObject( id74, id83, desc12 );
    var id84 = charIDToTypeID( "AntA" );
    descriptor.putBoolean( id84, antiAlias );
executeAction( circleSelection, descriptor, DialogModes.NO );
}

var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;


var newDocumentRef = documents.add(800,800, 72.0, "Circles",DocumentMode.RGB, DocumentFill.BACKGROUNDCOLOR);
newDocumentRef = null;


var centerX = 400;
var centerY = 400;
var radius = 150;

makeCircle(centerX-radius,centerY-radius,centerX+radius,centerY+radius,true);
activeDocument.selection.fill(foregroundColor);


var positionRing = [205,290,342,369]
for(b=1;b<=4;b++){

var x = 0
var y = 0
var littleRadius = positionRing[b-1];
var r = (6-b)*(6-b)*2
var counter = 0

	for(a=0;a<=2*Math.PI-(Math.PI)/(b*12);a = a +(Math.PI)/(b*6)){
	
		counter+=1;
		//remove the following line for optimal performance
		activeDocument.layers[0].name = "Processing, ring "+b+"/4 "+Math.round((a/(2*Math.PI-(Math.PI)/(b*12)))*1000)/10+"%";		

		x = Math.cos(a)*littleRadius;
		y = Math.sin(a)*littleRadius;
		
		makeCircle(x+centerX-r,y+centerY-r,x+centerX+r,y+centerY+r,true);
		activeDocument.selection.fill(foregroundColor,ColorBlendMode.NORMAL,100-b*18);
	}

}
activeDocument.selection.deselect();
activeDocument.layers[0].name = "Done...";

preferences.rulerUnits = defaultRulerUnits; 