Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Color Wheel
- # Joe, 19/12/2014
- import appuifw as A
- import graphics as G
- from math import cos,sin,pi
- rad=lambda x:x*pi/180.0
- def h2r(h,s,v):
- if s==0.0: return v,v,v
- i=int(h*6.0)
- f=(h*6.0)-i
- p=v*(1.0-s)
- q=v*(1.0-s*f)
- t=v*(1.0-s*(1.0-f))
- if i%6==0:return v,t,p
- if i==1:return q,v,p
- if i==2:return p,v,t
- if i==3:return p,q,v
- if i==4:return t,p,v
- if i==5:return v,p,q
- def gen(n=256):
- hsv=[(x*0.9/n,0.6,0.9) for x in xrange(n)]
- rgb=map(lambda x: tuple(map(lambda x:int(x*255), h2r(*x))),hsv)
- return rgb
- run=1
- w,h=G.sysinfo.display_pixels()
- img=G.Image.new((w,h))
- def stop():
- global run
- run=0
- def draw(x):
- c.blit(img)
- A.app.screen='full'
- c=A.Canvas(redraw_callback=draw)
- A.app.body=c
- A.app.exit_key_handler=stop
- N=360
- col=gen(N)
- cx,cy=w/2,h/2
- rr=80
- for i in range(h+1):
- img.line((0,h-i,w,h-i),col[i])
- draw(())
- A.e32.ao_sleep(1e-04)
- for i in range(N):
- x1=cx+rr*cos(rad(i))
- y1=cy+rr*-sin(rad(i))
- img.line((cx,cy,x1,y1),col[i],0,2)
- draw(())
- A.e32.ao_sleep(1e-04)
- while run:
- img.text((5,h-10),u'Color Wheel \u00a9 2014, Joe',0xffffff)
- draw(())
- A.e32.ao_sleep(1e-04)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement