Skip to main content
Participant
January 12, 2021
Answered

fill enclosed path with customized color use java script

  • January 12, 2021
  • 5 replies
  • 580 views

I found a method in pathitem class named fillPath. I tried it but nothing happened. Please help!

 

var myPathItem = doc.pathItems.add("myPath", lineSubPathArray);
var scolor = new SolidColor();
scolor.rgb.red = 173;
scolor.rgb.green = 41;
scolor.rgb.blue = 30;
myPathItem.fillPath(scolor, ColorBlendMode.NORMAL);
alert("111");
myPathItem.strokePath(ToolType.BRUSH);

 

I think my 'mypathitem' is right, cause without fillpath function, the strokepath function gives the right answer.

This topic has been closed for replies.
Correct answer JJMack

myPathItem.fillPath(scolor,ColorBlendMode.NORMAL,100,false,0,true,true);

5 replies

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
January 13, 2021

myPathItem.fillPath(scolor,ColorBlendMode.NORMAL,100,false,0,true,true);

JJMack
pixxxelschubser
Community Expert
Community Expert
January 13, 2021

Since the Scripting sub forums no longer exists ...

[ moved to Photoshop forum ]

 

erinferinferinf
Adobe Employee
Adobe Employee
January 13, 2021

Since the Scripting sub forums no longer exists ...

 

The Photoshop Scripting sub-forum was brought back as the "Actions and Scripting" topic:

 

https://community.adobe.com/t5/photoshop/bd-p/photoshop?page=1&sort=latest_replies&filter=all&topics=label-actionsandscripting

 

We even got the old messages from that topic out of the archive.

Ussnorway7605025
Legend
January 12, 2021
Peru Bob
Community Expert
Community Expert
January 12, 2021

This is the Using the Community forum (which is the forum for issues using the forums).
Please tell us what Adobe application you are using so that this can be moved to the proper forum for help.

JIAQI5FD7Author
Participant
January 13, 2021

Sorry, I'm using photoshop js scripting. The photoshop version is 20.0.4.

Below is my all of my code.

//app.displayDialogs = DialogModes.NO

function DrawShape(points) {
    while (app.documents.length) {
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES) //do not save anything we did 
    }
    var doc = app.documents.add(256, 256, 72, "triangle", NewDocumentMode.RGB, DocumentFill.TRANSPARENT);
    var lineSubPathArray = new Array();
    for (var j = 0; j < points.length; j++) {
        var lineArray = new Array();
        for (var i = 0; i < points[j].length; i++) {
            lineArray[i] = new PathPointInfo;
            lineArray[i].kind = PointKind.CORNERPOINT;
            lineArray[i].anchor = points[j][i];
            lineArray[i].leftDirection = lineArray[i].anchor;
            lineArray[i].rightDirection = lineArray[i].anchor;
        }
        lineSubPathArray[j] = new SubPathInfo()
        lineSubPathArray[j].closed = true;
        lineSubPathArray[j].operation = ShapeOperation.SHAPEXOR;
        lineSubPathArray[j].entireSubPath = lineArray;
        var myPathItem = doc.pathItems.add("myPath", lineSubPathArray);
        var scolor = new SolidColor();
        scolor.rgb.red = 173;
        scolor.rgb.green = 41;
        scolor.rgb.blue = 30;
        myPathItem.fillPath([scolor]);
        // myPathItem.fillPath(scolor)
        // myPathItem.strokePath(ToolType.BRUSH);
    }
}

// app.displayDialogs = DialogModes.NO
DrawShape([
    [
        [0, 0],
        [0, 256],
        [256, 0]
    ]
])
app.displayDialogs = DialogModes.ALL

 

pixxxelschubser
Community Expert
Community Expert
January 12, 2021

That seems to be a Photoshop question - is it, or not?

 

JIAQI5FD7Author
Participant
January 13, 2021

Yes. Sorry I should give more details.