Last active
January 30, 2022 15:37
-
-
Save sojack/a7dbbc8165dfadb2c0ad5b69e80a4437 to your computer and use it in GitHub Desktop.
Adobe illustrator - Phyllotaxis pattern generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mydoc = app.activeDocument; | |
var myLayer = mydoc.layers[0]; | |
// var myLayer = mydoc.layers.add(); | |
// myLayer.name = "myLayer"; | |
var c = 4; | |
var size = 5; | |
correction=size/2; | |
function degrees_to_radians(degrees) | |
{ | |
var pi = Math.PI; | |
return degrees * (pi/180); | |
} | |
for (var n = 0; n<1000; n++) { | |
var a = n * 137.5; | |
var r = c * Math.sqrt(n); | |
var x = Math.cos(degrees_to_radians(a))*r+306-correction; | |
var y = Math.sin(degrees_to_radians(a))*r+396+correction; | |
var circle = myLayer.pathItems.ellipse(y, x, size, size); | |
var mycolor = new RGBColor(); | |
mycolor.red = 255; | |
mycolor.green = (n)%256; | |
mycolor.blue = (n*a)%256; | |
circle.fillColor=mycolor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment