-
Notifications
You must be signed in to change notification settings - Fork 9
Outlines Groups Alignment
Fabian Morón Zirfas edited this page Jun 13, 2025
·
2 revisions
/*
This script create outlines from text
aligns some objects
builds a group
*/
// this is only prerequisite make a doc with some objects
// create a doc with a size of 200 w and h
var doc = app.documents.add({
documentPreferences: {
pageWidth: 200,
pageHeight: 200,
},
});
// some colors
var polycol_stroke = doc.colors.add({
name: "polycol_stroke",
model: ColorModel.PROCESS,
space: ColorSpace.RGB,
colorValue: [10, 0, 10],
});
var circlecol_fill = doc.colors.add({
name: "circlecol_fill",
model: ColorModel.PROCESS,
space: ColorSpace.RGB,
colorValue: [200, 255, 200],
});
// create a circle for styling
var circle = doc.pages.item(0).ovals.add({
geometricBounds: [25, 25, 175, 175],
strokeWeight: 0,
fillColor: circlecol_fill,
});
// create a background in white
var bg = doc.pages.item(0).rectangles.add({
geometricBounds: [0, 0, 200, 200],
strokeWeight: 0,
fillColor: doc.swatches.item(2) /* This is white */,
});
// create a text frame with a content "5"
var tf = doc.pages.item(0).textFrames.add({
geometricBounds: [25, 25, 175, 175],
contents: "5",
});
var firstPar = tf.paragraphs.item(0); // get the first paragraph
// set some properties
firstPar.properties = {
pointSize: 500,
hyphenation: false,
};
tf.fit(FitOptions.FRAME_TO_CONTENT); // now fit the box onto the character
/*
This is the gist.
- create outlines
- center the object
- make a group from polygon and rectangle bg
- apply some styling
- with the styling the circle gets visible again
*/
var poly = tf.createOutlines(true); // if true the original gets deleted returns an Array
poly[0].strokeWeight = 5; // give him a stroke
poly[0].strokeColor = polycol_stroke; // give him a stroke color
// center the polygon align expects an array
doc.align(
poly,
DistributeOptions.HORIZONTAL_CENTERS,
AlignDistributeBounds.PAGE_BOUNDS,
);
doc.align(
poly,
DistributeOptions.VERTICAL_CENTERS,
AlignDistributeBounds.PAGE_BOUNDS,
);
var groupArray = new Array(); // create an array for the objects we want to group
groupArray.push(bg); // push the bg into it
groupArray.push(poly[0]); // push the polygon into the Array
var the_group = doc.pages.item(0).groups.add(groupArray); // add a group to the first page
the_group.transparencySettings.blendingSettings.blendMode =
BlendMode.DIFFERENCE;
the_group.transparencySettings.blendingSettings.opacity = 77;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