• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Views

233

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

Votes

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

LATEST

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

 

Thank you

Votes

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