Skip to main content
Known Participant
January 25, 2023
Answered

Centrer des cercles sur chaque angle d'un cadre en javascript

  • January 25, 2023
  • 1 reply
  • 814 views

Bonjour à tous,

Je veux positionner 4 cercles sur un rectangle de mon plan de travail. Je veux que chaque cercle coïncide avec un des angles de mon rectangle sur mon plan de travail. J'ai essayé de réaliser cette tache avec Chat GPT mais il semble oublier quelque chose...

PM

This topic has been closed for replies.
Correct answer femkeblanco

 

Assuming the rectangle "CONTOUR" exists:

var w = h = 10;
var paths = app.activeDocument.pathItems;
var ps = paths["CONTOUR"].pathPoints;
for (var i = 0; i < ps.length; i++) {
    paths.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
}

(First line is diameter of circles in points.)

 

1 reply

Mylenium
Legend
January 25, 2023

And what exactly is the problem? The math? The specific script? You need to explain better. I don't even know what Chat GPT has tod o with it when you could just have drawn an example by hand.

 

Mylenium

polotroboAuthor
Known Participant
January 25, 2023

J'ai utilisé Chat GPT pour me générer 4 cercles et pour les positionner dans un calque.
Je veux maintenant que chacun de mes cercles soit aligné sur un des angles de mon contour qui s'appelle "CONTOUR"

            What I have                vs             What I want




femkeblanco
femkeblancoCorrect answer
Legend
January 25, 2023

 

Assuming the rectangle "CONTOUR" exists:

var w = h = 10;
var paths = app.activeDocument.pathItems;
var ps = paths["CONTOUR"].pathPoints;
for (var i = 0; i < ps.length; i++) {
    paths.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
}

(First line is diameter of circles in points.)