Change color of Path Item using JavaScript

New Here ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Hello, I'm using the following function below to draw some lines in photoshop.

 

What I'm wondering is, how does one change the color of a path before drawing it? I haven't been able to find anything on changing color for paths specifically. 

 

 

function drawLine(doc, start, stop) {

var startPoint = new PathPointInfo();

startPoint.anchor = start;

startPoint.leftDirection = start;

startPoint.rightDirection = start;

startPoint.kind = PointKind.CORNERPOINT;

var stopPoint = new PathPointInfo();

stopPoint.anchor = stop;

stopPoint.leftDirection = stop;

stopPoint.rightDirection = stop;

stopPoint.kind = PointKind.CORNERPOINT;

 

var spi = new SubPathInfo();

spi.closed = false;

spi.operation = ShapeOperation.SHAPEXOR;

spi.entireSubPath = [startPoint, stopPoint];

var line = doc.pathItems.add("Line", [spi]);

line.strokePath(ToolType.PENCIL);

line.remove();

};

drawLine(app.activeDocument, [100,100], [200,200]);

 

TOPICS
Actions and scripting, How to

Views

77

Likes

translate

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
community guidelines
Adobe Community Professional ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Use scriptListener to record changing the path color, then you can replace the color numbers with variables to script the color change. Kind of have to do this after you draw the path and convert it to a shape. 

Likes

translate

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
community guidelines
New Here ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Oh I didn't know about script listener. Awesome I will try that.

 

Thank you

Likes

translate

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
community guidelines