Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # joe 23/12/2014
- # star v2
- import appuifw as A
- import graphics as G
- from math import cos,sin,pi
- rad=lambda x:x*pi/180.0
- run=1
- def exit():
- global run
- run=0
- c=A.Canvas()
- A.app.screen='full'
- A.app.body=c
- w,h=c.size
- img=G.Image.new((w,h))
- A.app.exit_key_handler=exit
- 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
- def star(x,y,r,w,c):
- r1=r*.38
- n=5
- dA=rad(90)
- dB=rad(54)
- v0,v1=[],[]
- for i in range(n):
- x1=x+r*cos((2*pi/n)*i+dA)
- y1=y-r*sin((2*pi/n)*i+dA)
- x2=x+r1*cos((2*pi/n)*i+dB)
- y2=y-r1*sin((2*pi/n)*i+dB)
- v0.append((x1,y1))
- v1.append((x2,y2))
- vert = [
- v0[0][0], v0[0][1],
- v1[1][0], v1[1][1],
- v0[1][0], v0[1][1],
- v1[2][0], v1[2][1],
- v0[2][0], v0[2][1],
- v1[3][0], v1[3][1],
- v0[3][0], v0[3][1],
- v1[4][0], v1[4][1],
- v0[4][0], v0[4][1],
- v1[0][0], v1[0][1],
- v0[0][0], v0[0][1]
- ]
- img.polygon(vert,c,width=3)
- def rot(x,y,z):
- r=min(x,y)*.70
- ra=r*.40
- off=rad(z)
- for i in range(N):
- x2=x+r*cos((2*pi/N)*i+off)
- y2=y+r*sin((2*pi/N)*i+off)
- star(x,y,40,2,warna[i])
- star(x2,y2,15,2,warna[i])
- i=0
- N=15
- warna=gen(N)
- while run:
- i+=2
- if i>360:i=0
- img.clear(0)
- rot(w/2,h/2,i)
- c.blit(img)
- A.e32.ao_sleep(1E-08)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement