Skip to main content
Inspiring
Jul 10, 2020 3:30 PM UTC
Answered

Rectangle shape with javascript

Hi, 

 

Trying to get familiar with javaScript coding for Photoshop. Reading the documents a lot.

 

However, quick question. Is there any good tutorial on how to create / draw a new simple rectangle to the document? In Illustrator I find it very easy, but only examples I find for Photoshop is to manually draw out a path with coordinates for each point. Maybe this is the way to go? Want to see if there's any easier way to go with a simple shape like a rectangle. 

 

Thanks,

Mike

    This topic is closed to new replies. Start a new post to keep the conversation going.
    MikeCL9226041Correct answer
    Inspiring
    Jul 13, 2020 4:51 PM UTC

    I've managed to figure it out using script listener. Great tool to extract actions in photoshop. It is a bit hard to read though.. but doable. Just need to spend some time cleaning it up. 🙂

    4 replies

    pixxxelschubser
    Community Expert
    Community Expert
    Jul 19, 2020 8:41 PM UTC

    In this case, the use of AM code is the right choice.

    Translate
    pixxxelschubser
    Community Expert
    Community Expert
    Jul 19, 2020 3:52 PM UTC

    Hi @MikeCL-zZMTaZ,

    you answered your question yourself - but it's still not clear.

     

    @MikeCL-zZMTaZ wrote: "… how to create / draw a new simple rectangle to the document? …"

     

    What do you really want?

    What is a rectangle in your opinion?

    • a selection
    • a selection filled with pixel contents
    • other (pixel) layers contents
    • a work path
    • an path saved in Paths Panel
    • a vector shape
    • the canvas
    • a frame border
    • and so on …

     

    All of this can be done. With Javascript (Adobe ExtendScript) and/or Script Listener Code (Action-Manager-Code = AM-Code). But you always have to describe in detail what you really want. Otherwise you will always get no or wrong answers.

     

    BTW screenshot before and after and/or sample files are very helpful.

     

     

     

    Translate
    Inspiring
    Jul 19, 2020 7:19 PM UTC

    Yeah.. you're right.. Sorry... It was about a rectangle live shape filled with a color I was after. So I used Javascript (extend script), and in this case, together with AM-Code extracted from the script listener. I will try and be more precise in my questions.. Thanks for pointing that out!

    Translate
    MikeCL9226041AuthorCorrect answer
    Inspiring
    Jul 13, 2020 4:51 PM UTC

    I've managed to figure it out using script listener. Great tool to extract actions in photoshop. It is a bit hard to read though.. but doable. Just need to spend some time cleaning it up. 🙂

    Translate