# Archived:How to draw a circle in PySymbian

Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Tested with
Devices(s): Nokia N96

Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition

Article
Keywords: graphics, canvas
Created: cyke64 (15 Mar 2007)
Last edited: hamishwillee (08 May 2013)

## Overview

The article shows how to draw circles on canvas of the application body in Python. Ellipse function can be used for drawing circle, but arguments are not very user friendly. So you can write this new function for drawing a circle easier. Here is a function that will draw yellow circle with black outline.

## Code

`# 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.

Here's an example using this new circle function to show circles randomly

`# import required modulesimport e32from random import randint, choicefrom appuifw import * # Define exit functiondef quit():    App_lock.signal()app.exit_key_handler = quit app.screen = 'large' # Screen size set to 'large'c = Canvas()app.body = c sleep = e32.ao_sleepcolors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xffffff] # Function which draws circle with given radius at given co-ordinatedef circle(x,y,radius=5, outline=0, fill=0xffff00, width=1):  c.ellipse((x-radius, y-radius, x+radius, y+radius), outline, fill, width)  def rand_circle(n):  c.clear()  for i in range(n):    circle(randint(0,250), randint(0,180), randint(5,20), fill=choice(colors))    sleep(0.1) # Draw 40 circlesrand_circle(40) App_lock = e32.Ao_lock()App_lock.wait()  # Wait for exit event`

## Postconditions

Random Circles on Canvas