Let's quickly go through the code above. In the first line we create a circle shaped path with its center point at {x: 50, y: 50} with a radius of 25 pt. In the second line we change the position (the center point) of the circle shaped path to {x: 100, y: 100}

We can also move an item by a certain amount using the += operator.

The following example creates the same path as above, but instead of moving it to an absolute position, moves it 10pt to the right and 20pt down.

Scaling Items

In Illustrator you can scale an item by selecting it in the document, selecting the Scale Tool in the tool palette and clicking and dragging in the document to scale it. You can also change the center point of the scaling operation by clicking in the document.

Using Scriptographer you can also scale items. To scale both the width and height of an item by the same amount, you can call the item.scale(scale) of the item with a value between 0 and 1.

Scaling an Item Around a Center Point

By default the item.scale(scale) function scales an item around its center point. If you want to scale around a specific position, you can pass the scale function an optional center point: item.scale(scale, point).

In the third line, we make a variable called angle and pass it 360 degrees (a full rotation) divided by the amount of clones we will be making:

var angle = 360 / clones;

Next, we loop the amount of times we defined in the clones variable:

for (var i = 0; i < clones; i++) {

Basically what this line does is make a variable called i and start it with 0. Then it executes the block of code that is in between the { } brackets. After executing, it adds 1 to i and compares i to the clones variable. If i is still smaller then the clones variable, it executes the code block again.

Within the loop we clone the path using item.clone() and rotate it by angle * i from the top left point of its bounding rectangle. This means that when i is 0, the cloned path is rotated by 0 * angle and when i is 5 it rotates the cloned path by 5 * angle: