Skip to content

Instantly share code, notes, and snippets.

@moluapple
Created September 7, 2011 14:50
Show Gist options
  • Save moluapple/1200769 to your computer and use it in GitHub Desktop.
Save moluapple/1200769 to your computer and use it in GitHub Desktop.
[Illustrator, Scriptographer] Arrange Objects On Path
// yet another Scriptographer script
var oPath = document.selectedItems[0],
// u = oPath.reverse(),
len = oPath.length,
segments = oPath.segments,
parts = 20,
i = 0;
for (; i <= parts; i++) {
var point = oPath.getLocation(len / parts * i).point,
pointB = i > 0 ? oPath.getLocation(len / parts * i - 1).point : segments[0].point,
pointA = i < parts ? oPath.getLocation(len / parts * i + 1).point : segments[segments.length - 1].point,
path = new Path.Line(point, point + new Point(5, 0)),
text = new PointText({
content: i,
paragraphStyle: {
justification: 'center'
},
characterStyle: {
baselineShift: 4
}
}),
angle = (pointA - pointB).angle;
path.rotate(angle + 90, point);
text.rotate(angle);
text.point = point;
}
@moluapple
Copy link
Author

Result:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment