fill enclosed path with customized color use java script

New Here ,
Jan 12, 2021

Copy link to clipboard

Copied

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.

Most Valuable Participant
Correct answer by JJMack | Most Valuable Participant

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

TOPICS
Actions and scripting

Views

111

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

fill enclosed path with customized color use java script

New Here ,
Jan 12, 2021

Copy link to clipboard

Copied

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.

Most Valuable Participant
Correct answer by JJMack | Most Valuable Participant

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

TOPICS
Actions and scripting

Views

112

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 12, 2021 0
Most Valuable Participant ,
Jan 12, 2021

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2021 0
New Here ,
Jan 12, 2021

Copy link to clipboard

Copied

Yes. Sorry I should give more details.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2021 0
Adobe Community Professional ,
Jan 12, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2021 0
New Here ,
Jan 12, 2021

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2021 0
Most Valuable Participant ,
Jan 12, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2021 1
Most Valuable Participant ,
Jan 13, 2021

Copy link to clipboard

Copied

Since the Scripting sub forums no longer exists ...

[ moved to Photoshop forum ]

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 13, 2021 0
Adobe Employee ,
Jan 13, 2021

Copy link to clipboard

Copied

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...

 

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 13, 2021 0
Most Valuable Participant ,
Jan 13, 2021

Copy link to clipboard

Copied

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

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 13, 2021 1