home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
- ADOBE SYSTEMS INCORPORATED
- Copyright 2002 Adobe Systems Incorporated
- All Rights Reserved
-
- NOTICE: Adobe permits you to use, modify, and distribute this
- file in accordance with the terms of the Adobe license agreement
- accompanying it. If you have received this file from a source
- other than Adobe, then your use, modification, or distribution
- of it requires the prior written permission of Adobe.
- ***************************************************************/
-
- /***************************************************************
- Author: Henry Lee
- ***************************************************************/
-
- /***************************************************************
-
- This script will create a start on the current composition. If
- an object is currently selected, it will be converted into a
- geometric object, then reshaped into a star.
-
- Function:
- star(inRad,outRad,thepoints,offsetPoints)
-
- Arguments:
- <inRad> integer - the inner radius of the star
- <outRad> integer - the outer radius of the star
- <thepoints> integer - the number of points of the star
- <offsetPoints> integer - the angle at which to offset each
- point of the star.
-
- ***************************************************************/
-
- /***************************************************************
- To change the behavior of this script, make your changes below
- ***************************************************************/
-
- star(25, 45, 5, 0);
-
- /***************************************************************
- DO NOT EDIT BELOW THIS LINE
- ***************************************************************/
-
- function star(inRad, outRad, thepoints, offsetPoints) {
- comp = application.currentComposition;
- if (comp.selection.length < 1) {
- thestar = comp.createObject(LMGeometricType.path, comp.size.x/2, comp.size.y/2, 0);
- } else {
- thestar = comp.selection[0].convertType(LMGeometricType.path);
- }
-
- comp.saveSelection()
- var degToRads = Math.PI/180;
- var outOffset = offsetPoints * degToRads;
- var anglePerPoint = 2*Math.PI/thepoints;
- var anglePerKnot = anglePerPoint/2 + outOffset;
- var angleOffset = Math.PI/2; // so a point is straight up
- var startAngle = 0 + angleOffset;
- var endAngle = 2*Math.PI + angleOffset;
-
- //the first point
- var path = thestar.addPath(outRad*Math.cos(startAngle), -outRad*Math.sin(startAngle), 0);
-
- while(thestar.paths.length > 1)
- thestar.deletePath(1);
-
- // the second point
- path.addKnot(inRad*Math.cos(startAngle+anglePerKnot), -inRad*Math.sin(startAngle+anglePerKnot), 1);
- var currentAngle;
-
- for(currentAngle = startAngle+anglePerPoint; currentAngle < endAngle; currentAngle += anglePerPoint)
- {
- //outerPoint
- path.addKnot(outRad*Math.cos(currentAngle), -outRad*Math.sin(currentAngle), path.knots.length);
- //innerPoint
- path.addKnot(inRad*Math.cos(currentAngle+anglePerKnot), -inRad*Math.sin(currentAngle+anglePerKnot), path.knots.length);
- }
- path.closed = true;
- comp.restoreSelection();
- }
-
-