Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- from math import *
- from pyglet.gl import *
- from pyglet import clock
- from pyglet.clock import *
- x = y = []
- curCoordPos = 0
- SCREEN_WIDTH = 800
- SCREEN_HEIGHT = 600
- POINTS_NUM = 100
- CURVES_NUM = 30
- flag = a = 0
- def init_coord():
- i = a = 0
- global flag
- for i in xrange(CURVES_NUM):
- for j in xrange(POINTS_NUM):
- if flag == 0:
- rx = ((100 + 4 * i) * cos(a + 0.174))
- ry = ((100 + 4 * i) * sin(a))
- elif flag == 1:
- rx = (380 - i * 5) * sin(a + 0.2)
- ry = i * 8 * sin(a / 2) * cos(a) * cos(a)
- elif flag == 2:
- rx = (14 * (i - 16) * cos(a) + 5 * i) * sin(a + 0.2)
- ry = (9 * (i - 16) * sin(a) + 5 * i) * cos(a)
- elif flag == 3:
- rx = 20 * i * sin(a) * cos(a) * sin(a + 0.2)
- ry = (100 - 18 * i * sin(a) * cos(a * 2)) * cos(a)
- elif flag == 4:
- rx = (100 + 4 * i) * cos(a * 2 + 0.174)
- ry = ((100 + 4 * i) * sin(a))
- elif flag == 5:
- rx = (100 + 4 * i) * cos(a * 2 + 0.174)
- ry = ((100 + 4 * i) * cos(a + 0.174 * (i / 3)))
- x[i].append(400 + rx) #400 - SCREEN_WIDTH / 2
- y[i].append(300 + ry) #300 - SCREEN_HEIGHT / 2
- a += ((2 * pi) / POINTS_NUM)
- def dec_coord_cos():
- global curCoordPos
- curCoordPos -= 1;
- if(curCoordPos < 0):
- curCoordPos = POINTS_NUM - 1
- def draw():
- k=1
- glLoadIdentity()
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glBegin(GL_POINTS)
- for i in xrange(CURVES_NUM):
- for j in xrange(POINTS_NUM):
- glColor3f(k*i%1, 1 - k*j*i, k*j%1)
- glVertex2f((x[i][curCoordPos]), (y[i][j]))
- dec_coord_cos()
- if k>0:
- k -= 0.01
- else:
- k=1
- glEnd()
- dec_coord_cos()
- def reset():
- global x, y
- x = []
- y = []
- for i in xrange(CURVES_NUM):
- x.append([])
- y.append([])
- def main_loop(dt):
- init_coord()
- draw()
- window = pyglet.window.Window()
- window.set_size(SCREEN_WIDTH, SCREEN_HEIGHT)
- glEnable(GL_TEXTURE_2D)
- glClearColor(0.0, 0.0, 0.0, 0.0)
- reset()
- schedule_interval(main_loop, .03)
- @window.event
- def on_mouse_scroll(x, y, scx, scy):
- global flag
- reset()
- flag = (flag + 1) % 6
- pyglet.app.run()
Add Comment
Please, Sign In to add comment