Ask coding questions

← Back to all posts
how to get the background color of a turtle
AlexanderTarn (288)

So I have a turtle program with a circle, I want to fill this circle randomly with dots, but when I do a range of where I can put it, it makes a square and places dots outside the circle, anyway to stop that? I think background color is the best way so anyone know how to get that?

I posted the I kept secret it's on hot if you want to see it.

Answered by Nettakrim (693) [earned 5 cycles]
View Answer
Nettakrim (693)


window = turtle.Screen()
AlexanderTarn (288)

@Nettakrim this solution worked for me but may not in the future, but for now it works.

SixBeeps (5221)

Care to link the Repl?

AlexanderTarn (288)

@niorg2606 I would like to keep it secret because it's supposed to be a surprise

SixBeeps (5221)

@AlexanderTarn Okayyyyy then...
It sounds like you're moving left or right randomly clamped to the radius, then up and down the same way. This would cause a square to appear rather than a circle. What you need to do instead is pick a random angle and a random magnitude based on the radius, and use trigonometry to fill in the circle instead.