-
Notifications
You must be signed in to change notification settings - Fork 9
matrix
Fabian Morón Zirfas edited this page Jun 13, 2025
·
2 revisions

/*
This script creates a 2 dimensional array to create a matrix
you can access object by the number of the column or the row
X----0----1----2----3----4----5----6----7
*--------------------------------------->
C Y 0 0 0 0 0 0 0 0
| | | | | | | | |
O | 1 1 1 1 1 1 1 1
| | | | | | | | |
O | 2 2 2 2 2 2 2 2
| | | | | | | | |
R | 3 3 3 3 3 3 3 3
| | | | | | | | |
D | 4 4 4 4 4 4 4 4
| | | | | | | | |
I | 5 5 5 5 5 5 5 5
| | | | | | | | |
N | 6 6 6 6 6 6 6 6
| | | | | | | | |
A | 7 7 7 7 7 7 7 7
| | | | | | | | |
T | 8 8 8 8 8 8 8 8
| | | | | | | | |
E | 9 9 9 9 9 9 9 9
| | | | | | | | |
S V 10 10 10 10 10 10 10 10
So you can access the object in the upper left corner
via:
matrix[ 0][ 0] // upper left
matrix[ 7][10] // is the lower right corner
*/
var ph = 100; // page height for better handling
var pw = 300; // page width for better handling
var doc = app.documents.add({
/*Creae a doc with some settings*/
facingPages: false,
documentPreferences: {
pageHeight: ph,
pageWidth: pw,
},
});
var page = doc.pages[0]; // get the first page
var diam = 10; // the diameter of the the ovals
var matrix = new Array(); // his will hold all arrays this is X columns
/*
Now make a loop in a loop and create some circles
it calcs the position of the ovals and creates the 2 dim Array
*/
for (var x1 = 0; x1 < pw; x1 = x1 + diam) {
rows = new Array();
/*
we need a counter to create the matrix like this rows[count] = oval;
if we would use rows.push(oval) we would not need this counter
*/
var count = 0;
for (var y1 = 0; y1 < ph; y1 = y1 + diam) {
var y2 = y1 + diam; // now we have the y1 coord we need to create y2
var x2 = x1 + diam; // now we have the x1 coord we need to create x2
// create a oval
var oval = page.ovals.add({
geometricBounds: [y1, x1, y2, x2],
strokeWeight: 0,
fillColor: doc.swatches[3] /* This is black on creation */,
});
// now add the oval to the row
rows[count] = oval;
count++; // increase count
}
matrix.push(rows); // and add another row to the matrix
}
var X = 3; // this is how we now can select the objects
var Y = 5; // this is how we now can select the objects
alert(
"HI there I am the object of the type: " +
matrix[X][Y].constructor.name +
"\n" +
"at matrix coordinate:" +
" X: " +
X +
"|| Y: " +
Y,
); // set some properties
matrix[X][Y].strokeWeight = 25;
matrix[X][Y].strokeColor = doc.swatches[2];
matrix[X][Y].bringToFront();This wiki is mostly maintained by:
ff6347
Thanks to:
- JohnDarnell for fixing lots of typos.
- jsp for fixing lots of typos.
- ltfschoen for fixing typos.
- wridgers for adding more links.
- EugenTepin for several improvements.
- vamitul for improvements.
- abandonedbywolves for adding an example.
- Travis Weston
- Andy Dayton
Thanks to the students from my seminars 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
- Executing Shell Commands
- ExtendScript Toolkit
- File
- Folder
- Includes JSX
- Object Watch
- Read CSV
- Read In JSON From File And DONT Eval
- Storing Data In A Target Engine
- Target an application
- XML
- Isolate Layers With the Shy Setting
- Layer Duration Change
- Render And System Call
- Rename Layers
- SourceText to Keyframes from Array
- SourceText
- System Call
- app
- Colorbrewer
- ColorGroups
- 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
- Locked PageItems
- loops vs everyItem
- Masterspreads
- Matrix
- Objectstyles
- Outlines Groups Alignment
- Pages And Margins
- Pathfinder
- Placeholder Text
- Rectangles Ovals Polygons
- RulerOrigin
- Scripting Labels
- Select words at insertionPoint
- Simple Find And Change Grep with FC Query
- Simple Find And Change Grep
- Simple Find And Change Text
- Spiro
- Styles
- Table Cells
- Text Analysis ID FC
- Text Analysis
- Text Find Locations
- Text
- Transformation Matricies
- TransparencySettings
- XML creation and import