-2

I've been trying to write a function that would graph a circle.I tried using the distance formula in order to calculate my points:

def distance_form(x1, y1, x2, y2):
    d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

That didn't work, so I took a look at someone else's code for a circle.Here it is:

def circle(page, radius, g, h):
    for x in range(g, g + radius):
        y = h + (math.sqrt(radius ** 2 - ((x - g) ** 2)))
        plot(page, x, y)
        plot(page, x, 2 * h - y)
        plot(page, 2 * g - x, y)
        plot(page, 2 * g - x, 2 * h - y)

I'm decent at math, but I'm not really sure what this means.

Fibo36
  • 84
  • 4
  • 10
  • Google [tkinter canvas create circle](https://www.google.com/search?newwindow=1&biw=1280&bih=945&q=tkinter+canvas+create+circle&oq=tkinter+canvas+create+circle&gs_l=psy-ab.3...2139.2891.0.3017.8.6.0.0.0.0.0.0..0.0....0...1.1.64.psy-ab..8.0.0.Okm7VcQmnc0) The [first result](https://stackoverflow.com/questions/17985216/draw-circle-in-tkinter-python)... [This looks promising](http://zetcode.com/gui/tkinter/drawing/)... Try googling a bit before asking a question that has loads of easy to find documentation as asking bad question can get you blocked from asking question in the future. – Mike - SMT Aug 28 '17 at 21:43
  • tkinter doesn't have a method called `plot`. Are you using other libraries, such as matplotlib? – Bryan Oakley Aug 28 '17 at 21:53
  • @Brian Oakley Oh, I defined plot already to create a line – Fibo36 Aug 30 '17 at 00:17
  • Possible duplicate of [Draw circle in Tkinter (Python)](https://stackoverflow.com/questions/17985216/draw-circle-in-tkinter-python) – Anonymous Sep 04 '19 at 17:22

1 Answers1

2

I think the standard way of doing it is using create_oval.

oval = canvas.create_oval(x0, y0, x1, y1, options)

create_oval Documentation

Hope it Helps. Cheers!

Leo Van Deuren
  • 435
  • 2
  • 10