Javascript in the context of a drawing program opens a whole world of fun and useful possibilities for drawing things programmatically. My Draw Scripts folder is where I drop scripts which create new artwork according to user-defined parameters.

Link to zip archiveDownload The .zip Archive

To me, these are the most fun kinds of scripts to build. They can turn into hours and hours of mind-absorbing puzzlement. I certainly have more "almost there" attempts than finished ones. But even the completely botched ones yield a certain pleasure, kind of like losing a good game of chess.


Link to example image JET_Centroid.jsx
Finds the centroid (center of gravity) of selected triangles and other straight-sided multigon paths and draws a user-defined circle at that location. To use, make a selection which includes normal paths. Then call the script.


Link to example image JET_DimensionLine.jsx
Converts a straight path with two anchor points into a dimension label. The script expects the document to have these three styles defined:

The Dimension_Arrow Graphic Style can be of any stroke color or stroke weight, but should use Illustrator's Arrowhead Effect number 3 at both ends in order to scale so that the arrowheads are inboard of the witness lines. To easily add the styles to your document, open the accompanying file named JET_DimensionStyles.ai, copy the Group that is in the middle of the Artboard, and paste it into your document. Turn on Smart Guides. Use the Line tool to draw a line between two points. Run the script.


Link to example image Link to PDF file JET_FauxHalftone.jsx
Used in conjuction with Illustrator's Filter>Create>ObjectMosaic command. Creates vector faux "halftone dots" of Symbol Instances sized according to grayscale values of the paths created by the Object Mosaic Filter, effectively turning a raster image into a vector "halftone" in which the dots can be Instances of any Symbol.

Before using the script, create a Symbol named "Dot." Then select a raster image and Use the ObjectMosaic Filter to create an array of grayscale rectangles. Ungroup the results and leave the rectangles selected. Run the script. The script centers an instance of the Symbol named "Dot" on each rectangle, and then scales it according to the rectangle's grayscale value. The result is a "halftone" in which each dot is an instance of your Symbol. See the accompanying PDF for a full demonstration.


Link to example image JET_ReplaceWithSymbol.jsx
Replaces selected items with Instances of a Symbol from the Symbols Panel. The desired Symbol can be defined by its index number (its number of occurrance in the Panel).

The document must have at least one Symbol defined. Simply select some objects. Then run the script.


Link to example image Link to PDF file JET_Sphere.jsx
Creates a set of ellipses to form an axonometric sphere with user-defined number of latitude lines, longitude lines, and tilt angle.

Paths created by the script will have current fill/stroke appearances. Therefore, set current stroke to 1 pt or less. Set current fill to none. Run the script. Sphere will be drawn at the center of the Artboard, and will have diameter of 1".


Link to example image JET_RandomPatchworkSphere.jsx
Scales and rotates a user-specified number of copies of the topmost selected object so as to appear as randomly distributed on the surface of a sphere.

Because the copies are placed randomly, cycling of the Reset and Test buttons yields different distributions. After clicking Reset, you can change the Sphere Radius and Number of Patches values; then click Test to generate new results based on the new values. If used on a Symbol Instance, the Replace Symbol command can then be run on the results, to replace each scaled and rotated copy with an Instance of another Symbol at the same scale and rotation.