this project makes rectangles out of circles, by changing the size of the pen until it's only one pixel wide which leaves perfectly straight edges. I made another version of this a while ago and this is basically that except it uses Pythagorean Theorem to set the size more accurately. feel free to use this in your own projects.
The same script except with inputs for rounded edges. https://scratch.mit.edu/projects/1288017724/