# Thread: 1.1.0 pre-alpha version released

1. So, the 1.1.0 pre-alpha version is out there. Try it if you are interested.

Note that the API's aren't final and that the 1.1.0 build is actually already quite old, since posting it took a while. The much improved 1.1.2 build will hopefully follow soon.

2. Thank you!!!

Worth my patient wait.

3. Great, been waiting for it such a long time ...

First I noticed was that I downloaded version for S60 v1.1, and it wasn't able to install, so I tried 2.0 and it worked (I use n-gage -> 1.1), so please fix it, it may confuse somebody.

4. it's great, but one thing. are you sure that appuifw.Text.color, font, hlcolor and style should work? I can change anything, but the font (color, style...) is still the same. I don't know if I'm doing something wrong or it's a pre-alpha-bug.

5. A little program found on internet for Python 1.1.0 alpha only !
Code:
```#rotate cube

from math import sin,cos,pi
import appuifw,e32,sysinfo
from key_codes import *

#
#
#

return r*pi/180

def rotate_z(x,y,z,r):
rx = x * cos(rad) - y * sin(rad)
ry = x * sin(rad) + y * cos(rad)
rz = z
return rx,ry,rz

def rotate_x(x,y,z,r):
rx = x
ry = y * cos(rad) - z * sin(rad)
rz = y * sin(rad) + z * cos(rad)
return rx,ry,rz

def pers(x,y,z,dp=200):
rx = x * (z + dp)/dp
ry = y * (z + dp)/dp
return rx,ry

def set_exit():
global exit_flag
exit_flag = 1

global xrd
xrd += d

global zrd
zrd += d

#(x,y,z)
cpx = ((-40,-40,40),(40,-40,40),(40,40,40),(-40,40,40),
(-40,-40,-40),(40,-40,-40),(40,40,-40),(-40,40,-40))

con = ((0,1),(1,2),(2,3),(3,0),
(4,5),(5,6),(6,7),(7,4),
(0,4),(1,5),(2,6),(3,7))

size = sysinfo.displaypixels()
center_x = size[0]/2
center_y = size[1]/2

global exit_flag,xrd,zrd
exit_flag = 0
xrd = zrd = 2

c = appuifw.Canvas()
appuifw.app.screen=appuifw.MAIN_PANE

oldbody = appuifw.app.body
old_screen=appuifw.app.screen

appuifw.app.body = c

appuifw.app.exit_key_handler=set_exit

rx = 0
rz = 0

while exit_flag != 1:
pl = []
for p in cpx:
x,y,z = rotate_z(p[0],p[1],p[2],rz)
x,y,z = rotate_x(x,y,z,rx)
xx,yy = pers(x,y,z)
pl.append((int(xx)+center_x,int(yy)+center_y))

col = (0,128,0)
c.clear()
for pc in con:
c.line(pl[pc[0]],pl[pc[1]],col)
e32.ao_sleep(0.01)
rx += xrd
rz += zrd

appuifw.app.body = oldbody
appuifw.app.screen=old_screen```

Cool :-)

6. I am only able to download the SIS file from the forum.nokia.com website. The zip files that are downloaded are corrupt. I need those since I don't have a phone at hand to test the new API's. Anybody else experiencing the same problem?

7. Thanks for the cube example. It make playing with
the canvas much easier. The snake example
is a bit too long.

I added 4 lines to the cube.

def stop():
....global xrd, zrd
....xrd = zrd = 0
c.bind(EKeyDevice3, stop)

Now, you can stop the cube with the joy stick.
(Does anyone know why its name is Device3 ?)

8. I post 3 examples about contacts, canvas and sysinfo
at the code snippet repository.
http://www.bigbold.com/snippets/tags/series60

My canvas example is a bit shorter, and could be
a good start to play with canvas.

9. Currently it looks like pages don't allow anykind of downloads. Lets wait until Forum gets thing fixed and try then again

10. Originally posted by Zen13546
it's great, but one thing. are you sure that appuifw.Text.color, font, hlcolor and style should work? I can change anything, but the font (color, style...) is still the same. I don't know if I'm doing something wrong or it's a pre-alpha-bug.
Could you post the code that doesn't work?

Note that those attributes only apply to new text you insert, they won't affect the current contents in any way.

11. Originally posted by jplauril
Could you post the code that doesn't work?

Note that those attributes only apply to new text you insert, they won't affect the current contents in any way.
sorry. I had written the example when I downloaded the new SDK, and it didn't work. But I deleted it, and now when I read your post, I tried to write some example again, and it worked. I can't compare it with the previous code so I don't what did I wrong.

Sorry.

12. Hello ,

A upgraded version of cube with Zoom and unzoom , color change and a few bugs ;-)

Code:
```#rotate cube
# author : ?
# upgraded version by Cyke64

from math import sin,cos,pi
import appuifw,e32,sysinfo
from key_codes import *
Key1 =0x31
Key2 =0x32
Key3 =0x33
Key4 =0x34
Key5 =0x35
Key6 =0x36
Key7 =0x37
Key8 =0x38
Key9 =0x39
Key0 =0x30
KeyStar =0x2a
KeyDiese =0x23

#
#
#

return r*pi/180

def rotate_z(x,y,z,r):
rx = x * cos(rad) - y * sin(rad)
ry = x * sin(rad) + y * cos(rad)
rz = z
return rx,ry,rz

def rotate_x(x,y,z,r):
rx = x
ry = y * cos(rad) - z * sin(rad)
rz = y * sin(rad) + z * cos(rad)
return rx,ry,rz

def rotate_y(x,y,z,r):
rx = x * cos(rad) - z * sin(rad)
ry = y
rz = x * sin(rad) + z * cos(rad)
return rx,ry,rz

def pers(x,y,z,dp=200):
rx = x * (z + dp)/dp
ry = y * (z + dp)/dp
return rx,ry

def set_exit():
global exit_flag
exit_flag = 1

global xrd,mode
xrd += d
if mode == 1 or mode == 2:
xrd = 5*d

global yrd,mode
yrd += d
if mode == 1 or mode == 2:
yrd = 5*d

global zrd,mode
zrd += d
if mode == 1 or mode == 2 :
zrd = 5*d

def stop_rotation():
global zrd,xrd
zrd = xrd = 0

def zoom():
global cpx
t =[]
if abs(cpx[0][0])==1:
d=2
else:
d=1
for i in range(len(cpx)):
x,y,z = cpx[i]
t.append((x+((abs(x)/x)*d),y+((abs(y)/y)*d),z+((abs(z)/z)*d)))
cpx = tuple(t)

def unzoom():
global cpx
t =[]
if abs(cpx[0][0])==1:
d=2
else:
d=1

for i in range(len(cpx)):
x,y,z = cpx[i]
t.append((x-((abs(x)/x)*d),y-((abs(y)/y)*d),z-((abs(z)/z)*d)))
cpx = tuple(t)

def onkey7():
c.bind(Key7,zoom)

def change_mode():
global mode,infomode
if mode == 0 :
mode=1
infomode = u'view'
elif mode == 1:
mode=2
infomode = u'test view'
else:
mode=0
infomode = u'rotate'

def text_disp():
global istext
if istext==1:
istext=0
else:
istext=1

def ccolred(arg):
global colred
colred = (colred + arg)%256

def ccolgreen(arg):
global colgreen
colgreen = (colgreen + arg)%256

def ccolblue(arg):
global colblue
colblue = (colblue + arg)%256

#(x,y,z)
cpx = ((-4,-4,4),(4,-4,4),(4,4,4),(-4,4,4),
(-4,-4,-4),(4,-4,-4),(4,4,-4),(-4,4,-4))

con = ((0,1),(1,2),(2,3),(3,0),
(4,5),(5,6),(6,7),(7,4),
(0,4),(1,5),(2,6),(3,7))

size = sysinfo.displaypixels()
center_x = size[0]/2
center_y = size[1]/2

global exit_flag,xrd,yrd,zrd,mode,istext,infomode,colred,colgreen,colblue
exit_flag = 0
xrd = zrd = yrd = 0
mode = 0
istext=1
infomode = u'rotate'
colred=0
colgreen=0
colblue=0

c = appuifw.Canvas()
appuifw.app.screen=appuifw.MAIN_PANE

oldbody = appuifw.app.body
old_screen=appuifw.app.screen

appuifw.app.body = c

appuifw.app.exit_key_handler=set_exit
c.bind(EKeyDevice3,stop_rotation)
c.bind(Key2,unzoom)
c.bind(Key8,zoom)
c.bind(Key4,lambda:ccolgreen(-1))
c.bind(Key6,lambda:ccolgreen(1))
c.bind(Key1,lambda:ccolred(-1))
c.bind(Key7,lambda:ccolblue(-1))
c.bind(Key9,lambda:ccolblue(1))
c.bind(Key3,lambda:ccolred(1))
c.bind(EKeyYes,change_mode)
c.bind(Key0,text_disp)

rx = 0
ry = 0
rz = 0

while exit_flag != 1:
pl = []
for p in cpx:
x,y,z = rotate_z(p[0],p[1],p[2],rz)
x,y,z = rotate_x(x,y,z,rx)
x,y,z = rotate_y(x,y,z,ry)
xx,yy = pers(x,y,z)
pl.append((int(xx)+center_x,int(yy)+center_y))

col = (colred,colgreen,colblue)
c.clear()
for pc in con:
if mode == 2:
if pc == con[0] or pc == con[2] or pc == con[4] or pc == con[6]:
c.line(pl[pc[0]],pl[pc[1]],(255,0,0))
elif pc == con[1] or pc == con[3] or pc == con[5] or pc == con[7] :
c.line(pl[pc[0]],pl[pc[1]],(0,255,0))
elif pc == con[8] or pc == con[9] or pc == con[10] or pc == con[11] :
c.line(pl[pc[0]],pl[pc[1]],(0,0,255))
else:
c.line(pl[pc[0]],pl[pc[1]],col)

if istext == 1:
c.text((0,15),u'rd: (%d,%d) size: %d'%(xrd,zrd,abs(cpx[0][0])),(255,0,0))
if mode ==0 or mode ==1:
c.text((0,35),u'   : %d'%(colred),(255,0,0))
c.rectfill((2,26),(12,36),(colred,colgreen,colblue))
c.text((52,35),u'%d'%(colgreen),(0,255,0))
c.text((82,35),u'%d'%(colblue),(0,0,255))
c.rectfill((100,24),(50,34),(colred,colgreen,colblue))
c.text((0,190),u'[%s]'%infomode,(255,0,0))
e32.ao_sleep(0.001)
rx += xrd
rz += zrd
ry += yrd
if mode == 1 or mode == 2:
xrd = 0
yrd = 0
zrd = 0

appuifw.app.body = oldbody
appuifw.app.screen=old_screen```

13. Nice example, Cyke64

Let's collect some more ideas.
What other easy examples should we write
to demonstrate canvas?

Now we have snake and rotate_cube.
Here are my ideas
- hang man : use draw & text
- mine sweeper
- 15-square (1 missing)

Any more ideas?

14. The rotating cube is really nice, thanks. For real nerds here is the rotating icosahedron:

Replace con and cpx data in cube example by the following: (import math !)

s=72
h=s//2*(math.sqrt(5)-1)

cpx=((-h,-s,0),(h,-s,0),
(0,-h,s),(0,-h,-s),(s,0,h),
(s,0,-h), (-s,0,-h),(-s,0,h),(0,h,s),
(0,h,-s),(-h,s,0),(h,s,0))

con = ((0,1),(1,2),(2,0),
(1,3),(3,0),(1,4),
(4,5),(5,1),(0,6),
(6,7),(7,0),(2,8),
(2,4),(2,7),(3,5),
(3,6),(8,7),(8,4),
(3,9),(9,6),(6,10),
(7,10),(9,5),(5,11),
(4,11),(11,8),(8,10),
(10,9),(9,11),(10,11))

http://www.mathematik.uni-mainz.de/~.../sierpinski.py

is a little program using Canvas that displays a
fractal Sierpinski carpet, quite cute.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.