SHARE
TWEET

Untitled

a guest Mar 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from OpenGL.GL import *
  2. from OpenGL.GLUT import *
  3. import numpy as np
  4. from math import *
  5.  
  6. def circle(r=.25,xc=0,yc=0):
  7.     glBegin(GL_POLYGON)
  8.  
  9.     for theta in np.arange(0,2*pi,.001):
  10.         x=r*cos(theta)
  11.         y=r*sin(theta)
  12.         glVertex(x+xc,y+yc)
  13.      
  14.  
  15.     glEnd()
  16.  
  17.  
  18. def draw():
  19.     glClearColor(1,1,1,1)
  20.     glClear(GL_COLOR_BUFFER_BIT)
  21.     glColor3f(1,0,0)
  22.  
  23.     glBegin(GL_POLYGON)
  24.     glColor3f(.2,0,.1)
  25.     glVertex(-.45,-.5)
  26.     glVertex(-.45,-.55)
  27.     glVertex(-.25,-.55)
  28.     glVertex(-.25,-.4)
  29.     glVertex(-.3,-.4)
  30.     glVertex(-.3,-.5)
  31.     glVertex(-.45,-.5)
  32.     glEnd()
  33.  
  34.     glBegin(GL_POLYGON)
  35.     glColor3f(.2,0,.1)
  36.     glVertex(.45,-.5)
  37.     glVertex(.45,-.55)
  38.     glVertex(.25,-.55)
  39.     glVertex(.25,-.4)
  40.     glVertex(.3,-.4)
  41.     glVertex(.3,-.5)
  42.     glVertex(.45,-.5)
  43.     glEnd()
  44.  
  45.     glBegin(GL_POLYGON)
  46.     glColor3f(.9,.8,.3)
  47.     glVertex(.4,.5)
  48.     glVertex(-.4,.5)
  49.     glVertex(-.4,-.5)
  50.     glVertex(.4,-.5)
  51.     glEnd()
  52.  
  53.     glBegin(GL_LINE_LOOP)
  54.     glColor3f(.2,0,.1)
  55.     glVertex(.4,.5)
  56.     glVertex(-.4,.5)
  57.     glVertex(-.4,-.5)
  58.     glVertex(.4,-.5)
  59.     glEnd()
  60.    
  61.     glBegin(GL_QUADS)
  62.     glColor3f(.9,.8,.5)
  63.     glVertex(-.1,.5)
  64.     glVertex(.1,.5)
  65.     glVertex(.1,.7)
  66.     glVertex(-.1,.7)
  67.     glEnd()
  68.    
  69.     glBegin(GL_LINE_LOOP)
  70.     glColor3f(.2,0,.1)
  71.     glVertex(-.1,.5)
  72.     glVertex(.1,.5)
  73.     glVertex(.1,.7)
  74.     glVertex(-.1,.7)
  75.     glEnd()
  76.  
  77.     glBegin(GL_QUADS)
  78.     glColor3f(.9,.8,.5)
  79.     glVertex(-.05,.7)
  80.     glVertex(.05,.7)
  81.     glVertex(.05,.9)
  82.     glVertex(-.05,.9)
  83.     glEnd()
  84.  
  85.     glBegin(GL_LINE_LOOP)
  86.     glColor3f(.2,0,.1)
  87.     glVertex(-.05,.7)
  88.     glVertex(.05,.7)
  89.     glVertex(.05,.9)
  90.     glVertex(-.05,.9)
  91.     glEnd()
  92.    
  93.     glBegin(GL_POLYGON)
  94.     glColor3f(.2,.6,.9)
  95.     glVertex(.02,.96)
  96.     glVertex(.1,.97)
  97.     glVertex(.19,.96)
  98.     glVertex(.19,.84 )
  99.     glVertex(.1,.83)
  100.     glVertex(.02,.84)
  101.     glEnd()
  102.  
  103.     glBegin(GL_POLYGON)
  104.     glColor3f(.2,.6,.9)
  105.     glVertex(-.18,.96)
  106.     glVertex(-.1,.97)
  107.     glVertex(-.02,.96)
  108.     glVertex(-.02,.84 )
  109.     glVertex(-.1,.83)
  110.     glVertex(-.18,.84)
  111.     glEnd()
  112.    
  113.     glBegin(GL_POLYGON)
  114.     glColor3f(.5,.6,.7)
  115.     glVertex(.45,-.3)
  116.     glVertex(.65,-.3)
  117.     glVertex(.65,-.7)
  118.     glVertex(.45,-.7)
  119.     glEnd()
  120.  
  121.     for i in np.arange(-.3,-.7,-.09):
  122.         glBegin(GL_LINES)
  123.         glColor3f(.2,0,.1)
  124.         glVertex(.45,i)
  125.         glVertex(.65,i)
  126.         glEnd()
  127.  
  128.  
  129.        
  130.     glBegin(GL_POLYGON)
  131.     glColor3f(.5,.6,.7)
  132.     glVertex(-.45,-.3)
  133.     glVertex(-.65,-.3)
  134.     glVertex(-.65,-.7)
  135.     glVertex(-.45,-.7)
  136.     glEnd()
  137.  
  138.    
  139.  
  140.     for i in np.arange(-.3,-.7,-.09):
  141.         glBegin(GL_LINES)
  142.         glColor3f(.2,0,.1)
  143.         glVertex(-.45,i)
  144.         glVertex(-.65,i)
  145.         glEnd()
  146.  
  147.     glBegin(GL_LINES)
  148.     glColor3f(.2,0,.1)
  149.     glVertex(-.8,-.7)
  150.     glVertex(.8,-.7)
  151.     glEnd()
  152.    
  153.     glBegin(GL_LINES)
  154.     glColor3f(.2,0,.1)
  155.     glVertex(-.6,-.8)
  156.     glVertex(-.2,-.8)
  157.     glEnd()
  158.    
  159.     glBegin(GL_LINES)
  160.     glColor3f(.2,0,.1)
  161.     glVertex(.2,-.8)
  162.     glVertex(.6,-.8)
  163.     glEnd()
  164.  
  165.     glBegin(GL_LINES)
  166.     glColor3f(.2,0,.1)
  167.     glVertex(-.2,-.9)
  168.     glVertex(.2,-.9)
  169.     glEnd()
  170.  
  171.     glBegin(GL_POLYGON)
  172.     glColor3f(.6,.6,1)
  173.     glVertex(.3,0)
  174.     glVertex(.6,0)
  175.     glVertex(.6,-.1)
  176.     glVertex(.3,-.1)
  177.     glEnd()
  178.  
  179.     glBegin(GL_POLYGON)
  180.     glColor3f(.6,.6,1)
  181.     glVertex(.45,0.1)
  182.     glVertex(.55,0.1)
  183.     glVertex(.55,-.1)
  184.     glVertex(.45,-.1)
  185.     glEnd()
  186.  
  187.     glBegin(GL_POLYGON)
  188.     glColor3f(.6,.6,1)
  189.     glVertex(.3,.2)
  190.     glVertex(.6,.2)
  191.     glVertex(.6,.1)
  192.     glVertex(.3,.1)
  193.     glEnd()
  194.  
  195.     glBegin(GL_POLYGON)
  196.     glColor3f(.6,.6,1)
  197.     glVertex(.4,0.07)
  198.     glVertex(.5,0.07)
  199.     glVertex(.5,0.05 )
  200.     glVertex(.4,0.05)
  201.     glEnd()
  202.  
  203.  
  204.     glBegin(GL_POLYGON)
  205.     glColor3f(.6,.6,1)
  206.     glVertex(-.3,0)
  207.     glVertex(-.6,0)
  208.     glVertex(-.6,-.1)
  209.     glVertex(-.3,-.1)
  210.     glEnd()
  211.  
  212.     glBegin(GL_POLYGON)
  213.     glColor3f(.6,.6,1)
  214.     glVertex(-.45,0.1)
  215.     glVertex(-.55,0.1)
  216.     glVertex(-.55,-.1)
  217.     glVertex(-.45,-.1)
  218.     glEnd()
  219.  
  220.     glBegin(GL_POLYGON)
  221.     glColor3f(.6,.6,1)
  222.     glVertex(-.3,.2)
  223.     glVertex(-.6,.2)
  224.     glVertex(-.6,.1)
  225.     glVertex(-.3,.1)
  226.     glEnd()
  227.  
  228.     glBegin(GL_POLYGON)
  229.     glColor3f(.6,.6,1)
  230.     glVertex(-.4,0.07)
  231.     glVertex(-.5,0.07)
  232.     glVertex(-.5,0.05 )
  233.     glVertex(-.4,0.05)
  234.     glEnd()
  235.  
  236.     glBegin(GL_POLYGON)
  237.     glColor3f(.55,1,.9)
  238.     glVertex(-.2,.35)
  239.     glVertex(-.1,.35)
  240.     glVertex(-.1,.45 )
  241.     glVertex(-.2,.45)
  242.     glEnd()
  243.  
  244.    
  245.  
  246.    
  247.  
  248.  
  249.    
  250.    
  251.     glColor3f(.2,0,.6)
  252.     circle(.06,.1,.9)
  253.     glColor3f(.2,0,.6)
  254.     circle(.06,-.1,.9)
  255.     glColor3f(.9,1,1)
  256.     circle(.02,.1,.9)
  257.     glColor3f(.9,1,1)
  258.     circle(.02,-.1,.9)
  259.     glColor3f(1,0,.1)
  260.     circle(.03,.1,.4)
  261.  
  262.  
  263.     glFlush()
  264.  
  265.  
  266.  
  267. glutInit()
  268. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
  269. glutInitWindowSize(500,500)
  270. glutCreateWindow(b"WALLE")
  271. glutDisplayFunc(draw)
  272. glutMainLoop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top