半随机模式与Illustrator和Javascript

时间:2018-03-29 19:38:22

标签: javascript math

我想在Adobe Illustrator中创建一个像十六进制模式的迷彩,随机生成的模式就像我在互联网上找到的那样

View Image

我使用Javascript在Illustrator中随机着色六边形,这是我的结果

View Image

正如您所看到的,第一张图片具有更大的一种颜色的连接区域。这是我用来为六边形着色的Javascript

mySelection = app.activeDocument.selection;
myDoc = app.activeDocument;

if (mySelection instanceof Array)

{
selSwatches = myDoc.swatches.getSelected();

if(selSwatches.length != 0)
    for (i=0; i<mySelection.length; i++)
    {
        if(mySelection[i].typename == "PathItem" || mySelection[i].typename == "CompoundPathItem")
        {
            selItem = mySelection[i];
            selItem.filled = true;

            swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

            if(selItem.typename == "PathItem")
                selItem.fillColor = selSwatches[swatchIndex].color;
            else
                selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;

        }
    }
}

现在我的问题是:如何更改Javascript以获得更多连接空格?

0 个答案:

没有答案