Drawing Circle Function
Join the DZone community and get the full member experience.Join For Free
Just to make drawing a circle easier. Here is a function that will draw yellow circle with black outline.
# from appuifw import * # c = Canvas() # app.body = c def circle(x,y,radius=5, outline=0, fill=0xffff00, width=1): c.ellipse((x-radius, y-radius, x+radius, y+radius), outline, fill, width)You may use other default values. Then I create a function to show circles randomly
import e32 from random import randint, choice sleep = e32.ao_sleep colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xffffff] def rand_circle(n): c.clear() for i in range(n): circle(randint(0,176), randint(0,144), randint(5,20), fill=choice(colors)) sleep(0.1) # now show it rand_circle(30)
Opinions expressed by DZone contributors are their own.