I create a circle using create_oval() . How to divide it into sectors?
1 answer
To draw a sector, arc, or part of a circle create_arc() chord, there is a function create_arc() . Example:
from tkinter import * root = Tk() canvas = Canvas(root, width=300, height=300) canvas.pack() d = 360 // 36 colors = ['red', 'green', 'blue', 'yellow'] color_index = 0 for a in range(0, 360, d): # start - угол начала дуги, extent - "длина" дуги в градусах # style - может быть PIESLICE (сектор), CHORD ("хорда") или ARC (дуга). По-умолчанию PIESLICE canvas.create_arc(5, 5, 295, 295, start=a, extent=d, style=ARC, outline=colors[color_index]) color_index = (color_index+1) % len(colors) root.mainloop() - and how to close everything in a circle. I just need to turn this circle afterwards. - Oleg_Hudyma
- @Oleg_Hudyma, draw 36 arcs - you get a full circle. Attached a screenshot of the program. - insolor
- thanks a lot) - Oleg_Hudyma
|
