-
Notifications
You must be signed in to change notification settings - Fork 30
Spiro
fabiantheblind edited this page Nov 19, 2015
·
3 revisions
spiro.png
##Warning this code is a bit unstable, but nice ;)
/*
author: @fabiantheblind
This script creates a graphic line in circles
based on this processing sketch by PhiLho
http://forum.processing.org/topic/how-can-i-draw-this#25080000000995029
the size of the page
*/
var ph= 150;
var pw= 150;
// we need a doc
// use pw and phas size
var doc = app.documents.add({
documentPreferences:{
pageHeight:ph,
pageWidth:pw
}
});
// the page is already there
var page = doc.pages.item(0);
// get the center of the page
var cx = pw / 2;
var cy = ph / 2;
// define the initial radius
var init_rad = 0.9 *(pw / 2);
var radius = init_rad;
//this is the amplitude fpr the disturb
var amplitude = radius / 1;
// create a graphicLine
var gl = page.graphicLines.add();
var radians_angle; // this will hold the angle in radians
var rounds = 75; // how many rounds
//~ we need to count the path points.
//~ the first an second always exist in a graphic line
var count = 0;
var degree_step = 4;
// loop through the data.anchors
for(var degrees = 0; degrees < 360 *rounds; degrees+= (360/degree_step)){
// calculate the degree to radians
radians_angle = ((degrees/360)%360) * 2 * Math.PI;
// get the point
var point = gl.paths[0].pathPoints[count];
// set the disturb to 0 if you want straight lines
// calc the position on the circle
var x1 = cx + (radius ) * Math.cos(radians_angle);
var y1 = cy + (radius ) * Math.sin(radians_angle);
radius-= 0.2;
/**
* a graphicLine always has 2 path points
* so we need to add points only from the third index
*
*/
if(count < 2){
point.anchor = [x1,y1];
if(count%4 == 0 ) point.rightDirection = [x1, y1+radius];
if(count%4 == 1 ) point.rightDirection = [x1 - radius,y1];
if(count%4 == 2 ) point.rightDirection = [x1 , y1 - radius];
if(count%4 == 3 ) point.rightDirection = [x1 + radius ,y1 ];
}else{
point = gl.paths[0].pathPoints.add();
point.anchor = [x1,y1];
if(count%4 == 0 ) point.rightDirection = [x1, y1+radius];
if(count%4 == 1 ) point.rightDirection = [x1 - radius,y1];
if(count%4 == 2 ) point.rightDirection = [x1 , y1 - radius];
if(count%4 == 3 ) point.rightDirection = [x1 + radius ,y1 ];
}
// now make the circle smaller by every round
//if(degrees%360 == 0)radius-= ((init_rad)/rounds );
count++;
}
This wiki is maintained by:
fabiantheblind
Thanks to:
- JohnDarnell for fixing lots of typos.
- jsp for fixing lots of typos.
- ltfschoen for fixing typos.
- wridgers for adding more links.
Thanks to the students from the seminar for asking all those questions and making me start this wiki.
- adinaradke
- AnitaMei
- ce0311
- coerv
- felixharle
- FerdinandP
- Flave
- marche
- monkian
- natael
- OliverMatelowski
- PDXIII
- praktischend
- schlompf
- skaim
You are awesome.
- Arrays
- Classes
- Comments
- Conditionals
- Functions
- Inspect Properties
- Loops
- Objects
- Output And Interaction
- Recursive Functions
- Inspect Properties
- Variables And Operations
- Extended JavaScript Guide
- Bridge Talk
- Create And Read Files
- ExtendScript Toolkit
- File
- Folder
- Includes JSX
- Object Watch
- Read In JSON From File And DONT Eval
- Storing Data In A Target Engine
- Target an application
- XML
- app
- Colorbrewer
- Colors And Swatches
- Delay And View
- Dialogs
- Documents
- Duplicate And Transform
- Event AfterSave
- Export IDML
- ExtendScript in InDesign Scripting DOM
- Fonts
- GeometricBounds and Coordinates
- Get named pageItems
- Graphic Lines
- Groups
- HSL Color Wheel
- Images
- Includes
- InsertionPoints
- Layers
- Line Feeds And Carrige Returns
- Masterspreads
- Matrix
- Objectstyles
- Outlines Groups Alignment
- Pages And Margins
- Pathfinder
- Placeholder Text
- Rectangles Ovals Polygons
- RulerOrigin
- Select words at insertionPoint
- Simple Find And Change Grep with FC Query
- Simple Find And Change Grep
- Simple Find And Change Text
- Spiro
- Styles
- Text Analysis ID FC
- Text Analysis
- Text Find Locations
- Text
- Transformation Matricies
- TransparencySettings
- XML creation and import