curve.py

"""Draw curves in orthographic and perspective space.
   by stephan)
"""
from slut import *

class Atlantis(World):
    def onSetup(self):
        self.name = "NURBS"

    def onDrawOrtho(self):
        """Draw orthographic shapes."""
        #draw a single curves
        glColor4f(0.6, 0.6, 0.6, 1.0)
        curve([0, 200],
              [10, -100],
              [300, 300],
              [400, 200])
        curve([200, 0],
              [100, 0],
              [0, 100],
              [0, 200])
        #draw multiple curves
        glColor4f(1.0, 0.5, 0.5, 1.0)
        for x in range(10):
            curve([0, 200],
                  [50, 200],
                  [125, 400],
                  [150, 200-30*x],
                  [225, 200+50*x],
                  [250, 200-50*x],
                  [400, 200])

    def onDraw(self):
        """Draw perspective shapes."""
        glColor4f(1, 1.0, 1.0, 1.0)
        curve([-2, 0, 0],
               [-1.8, 1.0, -3],
               [-1.4, -1.0, 2],
               [0, 0.5, 1],
               [2, 0, 0])


atlantis = Atlantis()
atlantis.run()
Initiated by Stephan Hechenberger
Thanks to CADRE's 103