Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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):
  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)
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}