Javascript Geometric Pattern Script for Adobe Illustrator

Islamic geometric patterns open into a universe of form. The subdivision and repetition of the structures mirror the natural world.  Experimenting on paper with a compass and ruler, patterns mirrored each other. There was a sense of magic too it like watching a photograph fade into clarity in a darkroom tray.

While the contemplative process with a compass and ruler had its own pleasure, the pace interfered with the creative possibilities.  It seemed that software would perform the calculations with greater efficiency. Patterns could be explored simply by changing parameters rather than spending hours going up dead ends. Unfortunately, I wasn’t able to find anything that already written that would do the the job.  There were a few odds and end but nothing that quite fit the bill.

After exploring several options, writing a script for Adobe Illustrator seemed like the best solution.  It can be scripted in Javascript and, at least with my initial work, seemed intuitive to work with.  Results can also be easily exported and manipulated.

 Here are some of my results:


In addition to creating interesting patterns in their own right, the script could also be used to create guides that can be interpreted.


var docRef = documents.add();
var piRef = activeDocument.pathItems;
var size=200;
var sides=10;
var skip=6;
subdivide(output, size, skip);
function shape(sides, size){
output=new Array;
for (i = 0; i < (sides+1); i++) {
x= size * Math.cos(2 * Math.PI * i / sides);
y=size * Math.sin(2 * Math.PI * i / sides);
points=new Array(x,y);
return output;
function subdivide (output, size, skip) {
subdivided_output=new Array();
for (i = 0; i < output.length; i++) {
for (ii = 0; ii < output.length; ii++) {
// Create the tree shape
var pathRef = piRef.add();
// I got the list of these points by first drawing the tree in Illustrator
// I then displayed all point coordinates of the path using a script
pathRef.setEntirePath( subdivided_output )Â ;
//position shape
var left =100;
var top = size+400;
pathRef.position = new Array( left, top );



  • admin

    Hi Alex,
    You open it in File->Scripts.
    You can modify and reload the script to get different results.
    I was surprised how easy it was to work with Javascript in Illustrator.

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.