ETikhonov

Python GL

Sep 5th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from OpenGL.GL import *
  5. from OpenGL.GLU import *
  6. from OpenGL.GLUT import *
  7. from numpy import *
  8. import sys
  9. def init():
  10.     glClearColor(0.0, 0.0, 0.0, 1.0)
  11.     gluOrtho2D(-2.0, 2.0, -2.0, 2.0)
  12. def plotfunc():
  13.     glClear(GL_COLOR_BUFFER_BIT)
  14.     glColor3f(0.0,0.0,0.0)
  15.     glPointSize(1.0)
  16.     glBegin(GL_POINTS)
  17.     for a in arange(0.1,2.0,0.1):
  18.         for t in arange(-200.0,200.0,0.005):
  19.             x = sin(0.99*t)-0.7*cos(3.01*t)
  20.             y = cos(1.01*t)+0.1*sin(15.03*t)
  21.             glColor3f(sin(t)**2,cos(t)**2,sin(t)**2/2+cos(t)**2/2)
  22.             glVertex2f(x,y)
  23.     glEnd()
  24.     glFlush()
  25. def main():
  26.     glutInit(sys.argv)
  27.     glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB)
  28.     glutInitWindowPosition(0,0)
  29.     glutInitWindowSize(1366,768)
  30.     glutCreateWindow("Function Plotter")
  31.     glutDisplayFunc(plotfunc)
  32.     init()
  33.     glutMainLoop()
  34. main()
Advertisement
Add Comment
Please, Sign In to add comment