Thread View: adobe.scripting.indesign
5 messages
5 total messages
Started by Schelpie
Mon, 15 Dec 2008 21:07
Color object by pagenumber
Author: Schelpie
Date: Mon, 15 Dec 2008 21:07
Date: Mon, 15 Dec 2008 21:07
7 lines
930 bytes
930 bytes
Hi, I'm currently working in a yearbook and want to use a color-effect, but I don't know how to do it. The idea is to create a rainbow-effect (changing colors along the page sides). Does anyone knows/has a script or tutorial I can use for this? I will have about 300 pages in the book. Thanks in advance... Greetings, Schelpie
Re: Color object by pagenumber
Author: jongware
Date: Mon, 15 Dec 2008 22:03
Date: Mon, 15 Dec 2008 22:03
137 lines
3471 bytes
3471 bytes
For converting a number from a known range into a color value, and then especially a rainbow, you could use the HSB color model.
Let me think ... (making it up as I type):
Fill in the first page to be colored; the last page is calculated automatically. The routine draws a tiny rectangle on each page in the correct color, and adds it as a swatch as well. You probably want to convert them to CMYK before sending it off to print (perhaps with another script ;-) ). Adjust the calculation in HsbToRgb to get different start and ending points and hues.
var firstColoredPage = 10;
var lastColoredPage = app.activeDocument.pages.length;
var range = lastColoredPage - firstColoredPage;
var colorForPage = new Array(0,0,0);
for (i=0; i< range; i++)
{
HsbToRgb (i/range,1.0,1.0, colorForPage);
newrect = app.activeDocument.pages[firstColoredPage+i].rectangles.add({geometricBounds:[0,0,10,10]});
color = app.activeDocument.colors.add({name:"page"+(firstColoredPage+i), space:ColorSpace.RGB, colorValue:[colorForPage[0],colorForPage[1],colorForPage[2]]});
newrect.fillColor = color;
}
// from koders.com (modified):
function HsbToRgb(hue, saturation, brightness, dest)
{
var red = 0;
var green = 0;
var blue = 0;
if (saturation == 0) {
red = parseInt(brightness * 255.0 + 0.5);
green = red;
blue = red;
}
else {
var h = (hue - Math.floor(hue)) * 6.0;
var f = h - Math.floor(h);
var p = brightness * (1.0 - saturation);
var q = brightness * (1.0 - saturation * f);
var t = brightness * (1.0 - (saturation * (1.0 - f)));
switch (parseInt(h)) {
case 0:
red = (brightness * 255.0 + 0.5);
green = (t * 255.0 + 0.5);
blue = (p * 255.0 + 0.5);
break;
case 1:
red = (q * 255.0 + 0.5);
green = (brightness * 255.0 + 0.5);
blue = (p * 255.0 + 0.5);
break;
case 2:
red = (p * 255.0 + 0.5);
green = (brightness * 255.0 + 0.5);
blue = (t * 255.0 + 0.5);
break;
case 3:
red = (p * 255.0 + 0.5);
green = (q * 255.0 + 0.5);
blue = (brightness * 255.0 + 0.5);
break;
case 4:
red = (t * 255.0 + 0.5);
green = (p * 255.0 + 0.5);
blue = (brightness * 255.0 + 0.5);
break;
case 5:
red = (brightness * 255.0 + 0.5);
green = (p * 255.0 + 0.5);
blue = (q * 255.0 + 0.5);
break;
}
}
dest[0] = parseInt(red);
dest[1] = parseInt(green);
dest[2] = parseInt(blue);
}
Re: Color object by pagenumber
Author: jongware
Date: Mon, 15 Dec 2008 22:55
Date: Mon, 15 Dec 2008 22:55
8 lines
845 bytes
845 bytes
Make that 3rd line
var range = lastColoredPage - firstColoredPage + 1;
.. so the range for a start of 1 and end of 300 is 300. Not that anyone would notice, with the tiny color shift of one page to another.
Re: Color object by pagenumber
Author: Schelpie
Date: Mon, 22 Dec 2008 18:29
Date: Mon, 22 Dec 2008 18:29
1 lines
651 bytes
651 bytes
Jongware, thanks for your reply. It's a good basis for my book.
Re: Color object by pagenumber
Author: jongware
Date: Mon, 22 Dec 2008 20:52
Date: Mon, 22 Dec 2008 20:52
2 lines
875 bytes
875 bytes
I noticed a bit later on 2 boxes per spread may be put on the left page with a particular setup of your page rulers. I could program around that but it's way easier just to set the ruler to that position (whatsitcalled?) where the zero is in the middle of spreads; right-click the top ruler to change.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads