Changing Colors in Illustrator with Javascript

后端 未结 2 2004

I\'m very new to javascript and I am writing a script to find all pathItems of a specified fill color and change them to another fill color. This must be done in RGB or hex wi

2条回答
  •  故里飘歌
    2021-02-11 10:02

    Indeed you have a lot of erros in your script. Looking at the type of errors I suggest you to read Adobe Illustrator CS5 Reference: JavaScript or any JavaScript tutorial.

    In any case you can reduce your JavaScript errors by my modified version of your code.

    var fillRGBColor = function (pathItems, r, g, b){
        for (var i=0; i < pathItems.length; i++) {
            pathItems[i].fillColor.red = r;
            pathItems[i].fillColor.green = g;
            pathItems[i].fillColor.blue = b;
        }
    }
    
    fillRGBColor(app.activeDocument.pathItems, 50, 50, 50);
    

提交回复
热议问题