Sg2.9
Creating a Group and setting...
Recent RSS
Creating a Group and setting its transparency
From:  Ray Roddis
Date:  9. February 2012, 10:38

Hello Everyone,

I've recently discovered Scriptographer, and I must say it is brilliant. I've not done any programming for 25 plus years, and it does take me back. Being an Illustrator user for nearly 20 years, it's like a breath of fresh air for Illy.

Anyway, to my question:

I'm writing a script to draw user-defined grids (see below). I can set the transparency of each rectangle to 'darken', but what I'd really like to do is group all the rectangles together, and darken the whole group rather than each individual rectangle. I've tried a few things, but this has got me a little stuck, so I thought I'd ask for a little help :)

Thanks in advance,

Ray

Part of my script to draw the grid.

y = 0

for(var j = 1; j < 11; j++)

{

x = 0; // reset x

for(var i = 1; i < 11; i++)

{

var bottomLeft = new Point(x, y);
var rectSize = new Size(columnWidth[i], rowDepth[j]);
var myRect = new Path.Rectangle(bottomLeft, rectSize);
myRect.blendMode = 'darken'; // set Transparency to Darken
myRect.strokeColor = gridColor;

if (rowDepth[j] == 0)

{

myRect.remove();

}

if (columnWidth[i] == 0)

{

myRect.remove();

}

x = x + columnWidth[i];

}

y = y + rowDepth[j];

overallWidth = overallWidth + columnWidth[j];
overallDepth = overallDepth + rowDepth[j];

}

x = 0
y = 0

Re: Creating a Group and setting its transparency
From:  pqbd
Date:  9. February 2012, 11:01

//somewhere at the top, declare a new group
var group = new Group();

//after you make a myRect item, append it to the group
group.appendTop(myRect);

//When you're done, you can set the group blending like a regular item
group.blendMode='darken';

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Mosaic Staple Raster 24.03.10