Advertisement
phjoe

Rainbow

Dec 17th, 2014
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Rainbow
  2. # Joe, 18/12/2014
  3. import appuifw as A
  4. import graphics as G
  5.  
  6. def h2r(h,s,v):
  7.  if s==0.0: return v,v,v
  8.  i=int(h*6.0)
  9.  f=(h*6.0)-i
  10.  p=v*(1.0-s)
  11.  q=v*(1.0-s*f)
  12.  t=v*(1.0-s*(1.0-f))
  13.  if i%6==0:return v,t,p
  14.  if i==1:return q,v,p
  15.  if i==2:return p,v,t
  16.  if i==3:return p,q,v
  17.  if i==4:return t,p,v
  18.  if i==5:return v,p,q
  19.  
  20. def gen(n=256):
  21.  hsv=[(x*0.9/n,0.6,0.9) for x in xrange(n)]
  22.  rgb=map(lambda x: tuple(map(lambda x:int(x*255), h2r(*x))),hsv)
  23.  return rgb
  24.  
  25. run=1
  26. def stop():
  27.  global run
  28.  run=0
  29.  
  30. A.app.screen='full'
  31. A.app.body=c=A.Canvas()
  32. A.app.exit_key_handler=stop
  33. w,h=c.size
  34. img=G.Image.new((w,h))
  35.  
  36. n=int(40)
  37. col=gen(n)
  38. x,y=0,h
  39. rx,ry=w/2+40,h/2+40
  40. for i in range(h+1):
  41.  img.line((0,h-i,w,h-i),(123,174,5+i))
  42.  
  43. for i in range(n):
  44.  img.arc((x-rx-i,y-ry-i,x+rx+i,y+ry+i),0,90,col[i])
  45.  
  46. txt='Rainbow - Joe...'
  47. ltext=txt[:]
  48. for i in range(len(ltext)):
  49.  img.text((5+(i*8),h-10),u'%s' %ltext[i],col[i*2],(u'Sans MT 936_S60',26,G.FONT_BOLD))
  50.  
  51. while run:
  52.  c.blit(img)
  53.  A.e32.ao_sleep(1e-04)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement