Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a circle from origin

I am trying to draw a target like this: like this
(source: newscientist.com)

using turtle.

The problem is turtle includes the origin as part of the graph, as opposed to the origin being in the center. My question is, how do I get turtle draw a circle AROUND the origin rather than include it?

import turtle

radius = 100
turtle.speed(0)

for rings in range(10):


    turtle.circle(radius)
    radius += 10
like image 519
chopper draw lion4 Avatar asked Dec 22 '25 12:12

chopper draw lion4


2 Answers

import turtle

radius = 100
turtle.speed(0)

for rings in range(10):
    turtle.penup()
    turtle.goto(0, -radius)
    turtle.pendown()
    turtle.circle(radius)
    radius += 10
like image 151
timrau Avatar answered Dec 24 '25 01:12

timrau


It's nicer to use radius as the loop variable

import turtle

turtle.speed(0)

for radius in range(100, 200, 10):
    turtle.penup()
    turtle.goto(0, -radius)
    turtle.pendown()
    turtle.circle(radius)

Then you might wish to define a function

import turtle

turtle.speed(0)

def origin_circle(turtle, radius):
    turtle.penup()
    turtle.goto(0, -radius)
    turtle.pendown()
    turtle.circle(radius)

for radius in range(100, 200, 10):
    origin_circle(turtle, radius)
like image 25
John La Rooy Avatar answered Dec 24 '25 01:12

John La Rooy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!