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

How to make curvature on shapes with a script?

Explorer ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

In relation to the post on GitHub by Mike Hale and Vladimir Carrer I want to be able to add a curvature to the specific line, or to be more precize with an example, on a rectangle I just want to make curve on one of the sides, that also have to apply to every polygon.

 

In the loop:

for (i = 0; i < y; i++) {
	lineArray[i] = new PathPointInfo;
	lineArray[i].kind = PointKind.CORNERPOINT;
	lineArray[i].anchor = arguments[i];
	lineArray[i].leftDirection = lineArray[i].anchor;
	lineArray[i].rightDirection = lineArray[i].anchor;
}

 I know that lineArray[i].leftDirection = lineArray[i].anchor; and lineArray[i].rightDirection = lineArray[i].anchor; are responsible for creation of the curves. How could I do that in the function DrawShape()?

 

Thank you,

Damian

TOPICS
Actions and scripting , Windows

Views

412

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

correct answers 1 Correct answer

People's Champ , May 24, 2021 May 24, 2021

Well, for example, like this 🙂

function DrawShape() {
    
    var doc = app.activeDocument;
    var y = arguments.length;
    var i = 0;
    
    var lineArray = [];
    for (i = 0; i < y; i++) {
        lineArray[i] = new PathPointInfo;

        //lineArray[i].kind = PointKind.CORNERPOINT;
        //lineArray[i].anchor = arguments[i];
        //lineArray[i].leftDirection = lineArray[i].anchor;
        //lineArray[i].rightDirection = lineArray[i].anchor;

        lineArray[i].kind = PointKind.
...

Votes

Translate

Translate
Adobe
People's Champ ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Well, for example, like this 🙂

function DrawShape() {
    
    var doc = app.activeDocument;
    var y = arguments.length;
    var i = 0;
    
    var lineArray = [];
    for (i = 0; i < y; i++) {
        lineArray[i] = new PathPointInfo;

        //lineArray[i].kind = PointKind.CORNERPOINT;
        //lineArray[i].anchor = arguments[i];
        //lineArray[i].leftDirection = lineArray[i].anchor;
        //lineArray[i].rightDirection = lineArray[i].anchor;

        lineArray[i].kind = PointKind.SMOOTHPOINT;
        lineArray[i].anchor = [arguments[i][0], arguments[i][1]];
        lineArray[i].leftDirection = [arguments[i][2]!=undefined?arguments[i][2]:arguments[i][0], arguments[i][3]!=undefined?arguments[i][3]:arguments[i][1]];
        lineArray[i].rightDirection = [arguments[i][4]!=undefined?arguments[i][4]:arguments[i][0], arguments[i][5]!=undefined?arguments[i][5]:arguments[i][1]];
    }

    var lineSubPathArray = new SubPathInfo();
    lineSubPathArray.closed = true;
    lineSubPathArray.operation = ShapeOperation.SHAPEADD;
    lineSubPathArray.entireSubPath = lineArray;
    var myPathItem = doc.pathItems.add("myPath", [lineSubPathArray]);
    

    var desc88 = new ActionDescriptor();
    var ref60 = new ActionReference();
    ref60.putClass(stringIDToTypeID("contentLayer"));
    desc88.putReference(charIDToTypeID("null"), ref60);
    var desc89 = new ActionDescriptor();
    var desc90 = new ActionDescriptor();
    var desc91 = new ActionDescriptor();
    desc91.putDouble(charIDToTypeID("Rd  "), 0.000000); // R
    desc91.putDouble(charIDToTypeID("Grn "), 0.000000); // G
    desc91.putDouble(charIDToTypeID("Bl  "), 0.000000); // B
    var id481 = charIDToTypeID("RGBC");
    desc90.putObject(charIDToTypeID("Clr "), id481, desc91);
    desc89.putObject(charIDToTypeID("Type"), stringIDToTypeID("solidColorLayer"), desc90);
    desc88.putObject(charIDToTypeID("Usng"), stringIDToTypeID("contentLayer"), desc89);
    executeAction(charIDToTypeID("Mk  "), desc88, DialogModes.NO);
    
    myPathItem.remove();
}

                     
DrawShape([100, 100, 50,150, 150,50], [100, 200], [200, 200], [200, 100]);

 

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
Explorer ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

Yes, this would definitely do the job. Thank you r-bin.

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