Skip to main content
Inspiring
Nov 29, 2024 10:22 PM UTC
Question

JavaScript Share - Create 373 Cyan tints for printing and choosing colors from the printer you use.

This code will generate Cyan tints labled on a page with an 1/8" bleed for commercial printing applications.

 

var i = 0;
var ii = 0;
var y = 0;
var x = 0;
var ccount = 0;
var aDoc = app.documents.add();
for (; i < 374; ) {
if (x == 0 && y == 0) {
var Rect = aDoc.pathItems.rectangle(y - 9, x - 9, 36 + 9, -36 - 9)
} else {
if (y == 0 && x > 1 && i < 16) {
var Rect = aDoc.pathItems.rectangle(y - 9, x, 36, -36 - 9)
} else {
if (y == 0 && x == 576) {
var Rect = aDoc.pathItems.rectangle(y - 9, x, 36 + 9, -36 - 9)
} else {
if (x == 0 && i < 342) {
var Rect = aDoc.pathItems.rectangle(y, x -9 , 36 + 9, -36)
} else {
if (i == 357) {
var Rect = aDoc.pathItems.rectangle(y, x - 9, 36 + 9, -36 - 9)
} else {
if (i > 357 && i < 373) {
var Rect = aDoc.pathItems.rectangle(y, x, 36, -36 - 9)
} else {
if (i == 373) {
var Rect = aDoc.pathItems.rectangle(y, x, 36 + 9, -36 - 9)
} else {
if (x > 540 && y > 0 && y < 756) {
var Rect = aDoc.pathItems.rectangle(y, x, 36 + 9, -36)
} else {
var Rect = aDoc.pathItems.rectangle(y, x, 36, -36)
}
}
}
}
}
}
}
}
Rect.stroked = false;
Rect.filled = true;
var itemColor = new CMYKColor();
itemColor.cyan = ccount;
itemColor.magenta = 0;
itemColor.yellow = 0;
itemColor.black = 0;
var ccount = ccount + .1;
Rect.fillColor = itemColor;
//text
var textFrame = app.activeDocument.textFrames.add();
textFrame.contents = itemColor.cyan.toFixed(1);
textFrame.font = "JasmineUPC";
textFrame.size = 12;
var xp = x + 9;
var yp = y + 18;
textFrame.position = [xp, yp];
//textFrame.characterAttributes.color = [0, 0, 0];
var ii = ii + 1;
var i = i + 1;
var x = x + 36;
if (ii == 17) {
var ii = 0;
var x = 0;
var y = y + 36;
}
}

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

m1b
Community Expert
Community Expert
Dec 1, 2024 1:12 AM UTC

Thanks for sharing, @ShantiShaun!

 

P.S. Can you edit your post? If yes, please put the code into the </> code block style.

Translate
Inspiring
Dec 1, 2024 11:14 AM UTC

@m1b , I don't suppose anyone can edit their post that I know of.  I thought code would automatically parse.  On previous a previous post I saved my code as file and uploaded it and that worked and now I notice the code block </> icon here in the toolbar of this webapp.  I didn't notice that </> icon before until you used it in your message and my neurons fired and connected and I'm sure Neuralink has misinterpreted my learning as a hallucination again.  Neuralink probably thinks me learning how to control Illustrator though JavaScript is some kind of crime or something.  Bunch of stupid idiots working there.  That's off topic but it's true.

Translate