Listing 2674
Submitted by du, 5 February 2010
//Draw a bunch of lines of a fixed length from the centre of the circle function circle_radiants( origin, radiusStart, radiusEnd, increment ) { //Create an array to hold all of the points var points = new Array( ); var pointsIndex = 0; //Create an array to hold the subpath var subpath = new Array( ); var subpathIndex = 0; //Loop through the degrees of the circle for( angle = 0; angle <= 360; angle++ ) { //Only create a line where determined by the incrementations if( ( angle % increment ) == 0 ) { points[ pointsIndex ] = new Array( ); points[ pointsIndex ][ 0 ] = new PathPointInfo; points[ pointsIndex ][ 0 ].kind = PointKind.CORNERPOINT; points[ pointsIndex ][ 0 ].anchor = Array( ( ( radiusStart * Math.cos( angle * Math.PI/180 ) ) + origin[ 0 ] ), ( ( radiusStart * Math.sin( angle * Math.PI/180 ) ) + origin[ 1 ] ) ); points[ pointsIndex ][ 0 ].leftDirection = points[ pointsIndex ][ 0 ].anchor; points[ pointsIndex ][ 0 ].rightDirection = points[ pointsIndex ][ 0 ].anchor; points[ pointsIndex ][ 1 ] = new PathPointInfo; points[ pointsIndex ][ 1 ].kind = PointKind.CORNERPOINT; points[ pointsIndex ][ 1 ].anchor = Array( ( ( radiusEnd * Math.cos( angle * Math.PI/180 ) ) + origin[ 0 ] ), ( ( radiusEnd * Math.sin( angle * Math.PI/180 ) ) + origin[ 1 ] ) ); points[ pointsIndex ][ 1 ].leftDirection = points[ pointsIndex ][ 1 ].anchor; points[ pointsIndex ][ 1 ].rightDirection = points[ pointsIndex ][ 1 ].anchor; //Add the collection of points to the path subpath[ subpathIndex ] = new SubPathInfo( ); subpath[ subpathIndex ].operation = ShapeOperation.SHAPEXOR; subpath[ subpathIndex ].closed = false; subpath[ subpathIndex ].entireSubPath = points[ pointsIndex ]; pointsIndex++; subpathIndex++; } } return( subpath ); } //Save the current preferences var startRulerUnits = app.preferences.rulerUnits var startTypeUnits = app.preferences.typeUnits var startDisplayDialogs = app.displayDialogs //Set photoshop to use pixels and display no dialogs app.preferences.rulerUnits = Units.PIXELS app.preferences.typeUnits = TypeUnits.PIXELS app.displayDialogs = DialogModes.NO //First close all the open documents //while( app.documents.length ) //{ // app.activeDocument.close( ) //} //Create a document to work with //var docRef = app.documents.add( 3633, 1133, 300, "Circle" ); var docRef = app.activeDocument; var artLayerRef = docRef.artLayers.add( ); docRef.activeLayer = artLayerRef; //create the path item var shape = docRef.pathItems.add("A Linex", circle_radiants( Array( 1000, 0 ), 125, 100, 2 ) ) // stroke it so we can see something shape.strokePath(ToolType.BRUSH); // Reset the application preferences preferences.rulerUnits = startRulerUnits; preferences.typeUnits = startTypeUnits; displayDialogs = startDisplayDialogs;

