Calling polygon may be faster than a blit.
x,y = 20,20
arrow = [(0,0), (0,10), (2,8), (4,12), (6,11), (4,7), (7,7)]
canvas.polygon([(x+dx,y+dy) for dx,dy in arrow], 0, 0xffffff)
Here's an example app. It let you move cursor around.
When you press the select key, a red circle is drawn.
The longer you press, the bigger the circle.
Start with the usual stuff
import e32
from appuifw import *
from key_codes import *
class Keyboard(object):
def __init__(self):
self.state = {}
self.buffer= {}
def handle_event(self, event):
code = event['scancode']
if event['type'] == EEventKeyDown:
self.buffer[code]= 1
self.state[code] = 1
elif event['type'] == EEventKeyUp:
self.state[code] = 0
def pressing(self, code):
return self.state.get(code,0)
def pressed(self, code):
if self.buffer.get(code,0):
self.buffer[code] = 0
return 1
return 0
key = Keyboard()
app.body = canvas = Canvas(event_callback=key.handle_event)
def quit():
global running
running = 0
app.exit_key_handler = quit
running = 1
Then the main part of this specific app.
x,y = 20,20
arrow = [(0,0), (0,10), (2,8), (4,12), (6,11), (4,7), (7,7)]
while running:
if key.pressing(EScancodeUpArrow):
y -= 1
if key.pressing(EScancodeDownArrow):
y += 1
if key.pressing(EScancodeLeftArrow):
x -= 1
if key.pressing(EScancodeRightArrow):
x += 1
if key.pressed(EScancodeSelect):
r = 1
while key.pressing(EScancodeSelect):
r += 1
canvas.ellipse([(x-r,y-r),(x+r,y+r)], fill=0xff0000)
canvas.polygon([(x+dx,y+dy) for dx,dy in arrow], 0, 0xffffff)
e32.ao_sleep(0.03)
canvas.clear()
canvas.polygon([(x+dx,y+dy) for dx,dy in arrow], 0, 0xffffff)
e32.ao_sleep(0.01)