Over a million developers have joined DZone.

Drawing Circle Function

DZone's Guide to

Drawing Circle Function

· ·
Free Resource
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):
  for i in range(n):
    circle(randint(0,176), randint(0,144), randint(5,20), fill=choice(colors))

# now show it

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}