# Archived:How to draw a circle in PySymbian

Jump to: navigation, search
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.
Article Metadata

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 (31 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 modules
import e32
from random import randint, choice
from appuifw import *

# Define exit function
def 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_sleep
colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xffffff]

# Function which draws circle with given radius at given co-ordinate
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)

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 circles
rand_circle(40)

App_lock = e32.Ao_lock()
App_lock.wait() # Wait for exit event

## Postconditions

Random Circles on Canvas

## Related Links

This page was last modified on 31 May 2013, at 03:08.
56 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.