Playing with Scriptographer

While at work today I didn’t have anything to do so I decided to learn how to use the Illustrator plug-in called Scriptographer. Scriptographer is a pulg-in which enables you to write custom brushes, filters or generative stuff using Javascript. The above image shows my first attempt at creating a generative brush. Basically it draws a thick branch when you drag the mouse with smaller branches randomly branching out. Some of the smaller branches have lollipop looking things on the end and some don’t. I’ve included the code below. You can edit the scale of the effect and the colours of the circles and branches. Feel free to use it anywhere or modify it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
///////////////////////////////////////////////////////////////
/////////////////////////EDIT THESE////////////////////////////
///////////////////////////////////////////////////////////////

var circleColours = ['#CD00FF','#7400EF','#0666FF'];  //colour of the repeating circles
var rootLineColour = '#FF0000';  //colour of the main line
var branchColour = '#CCCCCC';
var effectScale = 30;  //size of the pattern

///////////////////////////////////////////////////////////////
/////////////////////DON'T EDIT BELOW//////////////////////////
///////////////////////////////////////////////////////////////

var rootPath;

function onMouseDown(event) {
    rootPath = new Path();
    rootPath.strokeWidth = (effectScale/11);
    rootPath.stokeColor = rootLineColour;
    rootPath.add(event.point);
}

function onMouseDrag(event) {

    rootPath.add(event.point);

    var rootToCircle = new Path();
    var circlePosition = (event.point+Point.random() * (effectScale*4))-(effectScale*2);
    var circleSize = Math.random() * (effectScale/3*2);

    rootToCircle.stokeColor = branchColour;

    rootToCircle.add(circlePosition);
    rootToCircle.add(event.point);

    var openBranch = new Path();
    openBranch.stokeColor = branchColour;
    var openBranchEnd = (event.point+Point.random() * (effectScale*4))-(effectScale*2);
    var openBranchStart = (event.point+Point.random() * (effectScale/3))-(effectScale/7);

    openBranch.add(openBranchEnd);
    openBranch.add(openBranchStart);

    var circle = new Path.Circle(circlePosition, circleSize);

    for (var i=0;i<circleColours.length;i++)
    {
         circleSize -= (effectScale/6);
         var repeatCircle = new Path.Circle(circlePosition, circleSize);
         repeatCircle.strokeColor = circleColours[i];
    }
}
Posted toIllustrator