Discuss Scratch

secretagent123
Scratcher
1000+ posts

Drawing a circle using a radius.

Hello.
How do I draw a circle with the pen using only the radius as an input.
deesawhney
Scratcher
97 posts

Drawing a circle using a radius.

clear
set [radius] to [5]
set [turn] to [0]
repeat (360)
pen up
go to x: (0) y: (0)
point in direction (turn)
move (radius) steps
pen down
pen up
change (turn) by (1)
end

This works well enough for me. If you want to fill in the circle, take out the pen up blocks.
secretagent123
Scratcher
1000+ posts

Drawing a circle using a radius.

deesawhney wrote:

clear
set [radius] to [5]
set [turn] to [0]
repeat (360)
pen up
go to x: (0) y: (0)
point in direction (turn)
move (radius) steps
pen down
pen up
change (turn) by (1)
end

This works well enough for me. If you want to fill in the circle, take out the pen up blocks.
Thank you for answering quickly.
SparshG
Scratcher
500+ posts

Drawing a circle using a radius.

pen down
repeat (360)
go to x: ((centerOfCircleX)+((rad) * ([cos v] of (angle)))) y: ((centerOfCircleY)+((rad) * ([sin v] of (angle))))
change [angle v] by (1)
end

To improve the quality more, you can increase repeat to say 720, and change angle by 0.5 such that 0.5 * 720 = 360

If you notice, decreasing the repeats will make polygons. If you make repeat to 4, change angle by 90, (again 4*90=360) you should get a square. In fact circle is just we are making polygons but with so many vertices that it looks like circle ;D

Last edited by SparshG (Dec. 24, 2020 18:21:08)

deesawhney
Scratcher
97 posts

Drawing a circle using a radius.

SparshG wrote:

pen down
repeat (360)
go to x: ((centerOfCircleX)+((rad) * ([cos v] of (angle)))) y: ((centerOfCircleY)+((rad) * ([sin v] of (angle))))
change [angle v] by (1)
end

This works better than mine; it draws lines between the points instead of dots

Powered by DjangoBB