Beispiel #1
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        #set basic coord system
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -40))

        ol.color3(0.0, 0.0, 1.0)
        ol.scale3((1., 1., 1.))

        #for i in range(10):
        #    x = random()*40-20
        #    y = random()*40-20
        #x = randint(-20,20)
        #y = randint(-20,20)
        #    square(x,y,.1)

        # truly randomly sampled by image vals
        #for i in range(20):
        #    x,y,val = rndlena()
        #    ol.color3(0.0,0.0,val/255.)
        #    square(x*40./SIZEX-20,y*40/SIZEY-20,.1)

        #totally random, weighted by image value
        for i in range(20):
            x = randint(0, SIZEX - 1)
            y = randint(0, SIZEY - 1)
            #val = lena.getpixel((x,y))
            #val = 1.-exp(-.5*lenadat[x*SIZEX+y]/255.)
            val = lenadat[x * SIZEX + y] / 255. * .77
            ol.color3(0.0, 0.0, val)
            square(x * 40. / SIZEX - 20, y * 40 / SIZEY - 20, .05)
Beispiel #2
0
    def draw(self):

        self.x_phase = 0.4*cos(1.7 * lux.time * self.RATE) + 0.6*cos(0.7 * lux.time * self.RATE)
        self.y_phase = cos(2.2 * lux.time * self.RATE)
        self.z_phase = cos(5.7 * lux.time * self.RATE)
        self.z_ratio = 2 + cos(0.1 * lux.time * self.RATE)

        ol.loadIdentity3()
        ol.loadIdentity()

        ol.perspective(20, 1, 1, 100)
        ol.translate3((0, 0, -10))
        ol.scale3((0.5, 0.5, 0.5))

        ol.rotate3Z(lux.time * pi * 0.01)
        ol.rotate3X(lux.time * pi * 0.025)
        ol.rotate3Y(lux.time * pi * 0.013)

        ol.color3(*(self.color_cycle()))

        ol.begin(ol.POINTS)
        decay_factor = 1
        first_point = None
        for i in range(self.SAMPLES_PER_FRAME):
            theta = float(i) / self.SAMPLES_PER_FRAME * self.MAX_THETA
            x = sin(self.x_ratio * theta + self.x_phase)
            y = sin(self.y_ratio * theta + self.y_phase)
            z = sin(self.z_ratio * theta + self.z_phase)
            if (i == 0):
                first_point = (x * decay_factor, y * decay_factor, z * decay_factor)
            ol.vertex3((x * decay_factor, y * decay_factor, z * decay_factor))
            decay_factor = decay_factor * self.decay
        ol.vertex3(first_point)
        ol.end()
Beispiel #3
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        # set basic coord system
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -40))

        ol.color3(0.0, 0.0, 1.0)
        ol.scale3((1.0, 1.0, 1.0))

        # for i in range(10):
        #    x = random()*40-20
        #    y = random()*40-20
        # x = randint(-20,20)
        # y = randint(-20,20)
        #    square(x,y,.1)

        # truly randomly sampled by image vals
        # for i in range(20):
        #    x,y,val = rndlena()
        #    ol.color3(0.0,0.0,val/255.)
        #    square(x*40./SIZEX-20,y*40/SIZEY-20,.1)

        # totally random, weighted by image value
        for i in range(20):
            x = randint(0, SIZEX - 1)
            y = randint(0, SIZEY - 1)
            # val = lena.getpixel((x,y))
            # val = 1.-exp(-.5*lenadat[x*SIZEX+y]/255.)
            val = lenadat[x * SIZEX + y] / 255.0 * 0.77
            ol.color3(0.0, 0.0, val)
            square(x * 40.0 / SIZEX - 20, y * 40 / SIZEY - 20, 0.05)
Beispiel #4
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        for i in range(2):
            ol.loadIdentity3()
            ol.perspective(20, 1, 1, 100)
            ol.translate3((0, 0, -20))

            if (i == 1):
                ol.color3(1.0, 1.0, 0.0)
                ol.translate3((cos(lux.time / 2.0), cos(lux.time / 3.0),
                               cos(lux.time / 7.0)))
                ol.rotate3Z(lux.time * pi * 0.1 * lux.TwoCubes_simple_rate)
                ol.rotate3X(lux.time * pi * 0.25 * lux.TwoCubes_simple_rate)
                ol.rotate3Y(lux.time * pi * 0.13 * lux.TwoCubes_simple_rate)
            else:
                ol.color3(0.0, 1.0, 1.0)
                ol.scale3((0.6, 0.6, 0.6))
                ol.translate3((cos(lux.time / 3.2), cos(lux.time / 2.6),
                               cos(lux.time / 5.4)))
                ol.rotate3Z(lux.time * pi * 0.14 * lux.TwoCubes_simple_rate)
                ol.rotate3X(lux.time * pi * 0.53 * lux.TwoCubes_simple_rate)
                ol.rotate3Y(lux.time * pi * 0.22 * lux.TwoCubes_simple_rate)

            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1, -1, -1))
            ol.vertex3((1, -1, -1))
            ol.vertex3((1, 1, -1))
            ol.vertex3((-1, 1, -1))
            ol.vertex3((-1, -1, -1))
            ol.vertex3((-1, -1, 1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3((1, 1, 1))
            ol.vertex3((-1, 1, 1))
            ol.vertex3((-1, -1, 1))
            ol.vertex3((1, -1, 1))
            ol.vertex3((1, 1, 1))
            ol.vertex3((1, 1, -1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3((1, -1, -1))
            ol.vertex3((1, -1, 1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1, 1, 1))
            ol.vertex3((-1, 1, -1))
            ol.end()
Beispiel #5
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        ol.color3(1.0, 0.0, 1.0);
        font = ol.getDefaultFont()
        s = "Lux!"
        w = ol.getStringWidth(font, 0.2, s)
        ol.drawString(font, (-w/2,0.1), 0.2, s)

        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        for i in range(2):

            if (i == 1):
                ol.color3(1.0,1.0,0.0);
            else:
                ol.color3(0.0,1.0,1.0);
                    
            ol.scale3((0.6, 0.6, 0.6))
            ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
            ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
            ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)
            
            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1, -1, -1))
            ol.vertex3(( 1, -1, -1))
            ol.vertex3(( 1,  1, -1))
            ol.vertex3((-1,  1, -1))
            ol.vertex3((-1, -1, -1))
            ol.vertex3((-1, -1,  1))
            ol.end()

            ol.begin(ol.LINESTRIP);
            ol.vertex3(( 1,  1,  1))
            ol.vertex3((-1,  1,  1))
            ol.vertex3((-1, -1,  1))
            ol.vertex3(( 1, -1,  1))
            ol.vertex3(( 1,  1,  1))
            ol.vertex3(( 1,  1, -1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3(( 1, -1, -1))
            ol.vertex3(( 1, -1,  1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1,  1,  1))
            ol.vertex3((-1,  1, -1))
            ol.end()
Beispiel #6
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        for i in range(2):
            ol.loadIdentity3()
            ol.perspective(20, 1, 1, 100)
            ol.translate3((0, 0, -20))

            if (i == 1):
                ol.color3(1.0,1.0,0.0);
                ol.translate3((cos(lux.time/2.0), cos(lux.time/3.0), cos(lux.time/7.0)))
                ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
                ol.rotate3X(lux.time * pi * 0.25 * lux.simple_rate)
                ol.rotate3Y(lux.time * pi * 0.13 * lux.simple_rate)
            else:
                ol.color3(0.0,1.0,1.0);
                ol.scale3((0.6, 0.6, 0.6))
                ol.translate3((cos(lux.time/3.2), cos(lux.time/2.6), cos(lux.time/5.4)))
                ol.rotate3Z(lux.time * pi * 0.14 * lux.simple_rate)
                ol.rotate3X(lux.time * pi * 0.53 * lux.simple_rate)
                ol.rotate3Y(lux.time * pi * 0.22 * lux.simple_rate)
            
            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1, -1, -1))
            ol.vertex3(( 1, -1, -1))
            ol.vertex3(( 1,  1, -1))
            ol.vertex3((-1,  1, -1))
            ol.vertex3((-1, -1, -1))
            ol.vertex3((-1, -1,  1))
            ol.end()

            ol.begin(ol.LINESTRIP);
            ol.vertex3(( 1,  1,  1))
            ol.vertex3((-1,  1,  1))
            ol.vertex3((-1, -1,  1))
            ol.vertex3(( 1, -1,  1))
            ol.vertex3(( 1,  1,  1))
            ol.vertex3(( 1,  1, -1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3(( 1, -1, -1))
            ol.vertex3(( 1, -1,  1))
            ol.end()

            ol.begin(ol.LINESTRIP)
            ol.vertex3((-1,  1,  1))
            ol.vertex3((-1,  1, -1))
            ol.end()
Beispiel #7
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        #set basic coord system
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -40))

        ol.color3(0.0,0.0,1.0);
        ol.scale3((1., 1., 1.))

        #for i in range(10):
        #    x = random()*40-20
        #    y = random()*40-20
            #x = randint(-20,20)
            #y = randint(-20,20)
        #    square(x,y,.1)

        #lux.time()
        #sleep(0.1)

        #for i in range(20):
        #    x,y,val = rndlena()
        #    ol.color3(0.0,0.0,val/255.)
        #    square(x*40./SIZEX-20,y*40/SIZEY-20,.1)
        
        #ol.color3(1.0,0.0,0.)        
        #square(10*.4-20,10*.4-20,.1)

        self.ROW+=3
        if self.ROW >= SIZEY:
            self.ROW=self.phase
            self.phase += 1
            if self.phase == 3: self.phase=0
        j=self.ROW
        
        for i in range(SIZEX):
            ol.color3(0.0,0.0,lena.getpixel((i,j))/255.)
            square(i*40./SIZEX-20.,j*40./SIZEY-20.,.1)
                
    def draw(self):
        self.tweener.add_tween(self, scale_factor=0.25, time_scale = 1.0, duration=0.1, \
                               easing=pytweener.Easing.Expo.ease_in_out)

        ol.loadIdentity()
        ol.loadIdentity3()
        ol.translate3((-0.1, 0.0, 0.0))
        ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor))

        # Spawn photons randomly
        if len(self.photons) < MAX_PHOTONS and random.random(
        ) < SPAWN_THRESHOLD:
            p = Photon()
            self.photons.append(p)

        # Draw photons
        dt = self.time_scale * (lux.time - self.last_time)
        self.last_time = lux.time
        self.tweener.update(lux.time - self.last_time)

        for p in self.photons:
            p.update(dt, self.photon_speed)
            p.draw()

        ol.color3(1.0, 1.0, 1.0)
        font = ol.getDefaultFont()
        s = "LASER"
        w = ol.getStringWidth(font, 1.0, s)
        ol.drawString(font, (-w / 2, 1.1), 1.0, s)

        # Draw the bounding box, with a very small hole in it.
        ol.color3(0.0, 1.0, 0.0)
        ol.begin(ol.LINESTRIP)
        ol.vertex3((CAVITY_SIZE[0] / 2, 0.1, 0.0))
        ol.vertex3((CAVITY_SIZE[0] / 2, CAVITY_SIZE[1] / 2, 0.0))
        ol.vertex3((-CAVITY_SIZE[0] / 2, CAVITY_SIZE[1] / 2, 0.0))
        ol.vertex3((-CAVITY_SIZE[0] / 2, -CAVITY_SIZE[1] / 2, 0.0))
        ol.vertex3((CAVITY_SIZE[0] / 2, -CAVITY_SIZE[1] / 2, 0.0))
        ol.vertex3((CAVITY_SIZE[0] / 2, -0.1, 0.0))
        ol.end()
    def draw(self):
        self.tweener.add_tween(self, scale_factor=0.25, time_scale = 1.0, duration=0.1, \
                               easing=pytweener.Easing.Expo.ease_in_out)

        
        ol.loadIdentity()
        ol.loadIdentity3()
        ol.translate3((-0.1, 0.0, 0.0))
        ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor))

        # Spawn photons randomly
        if len(self.photons) < MAX_PHOTONS and random.random() < SPAWN_THRESHOLD:
            p = Photon();
            self.photons.append(p)

        # Draw photons
        dt = self.time_scale * (lux.time - self.last_time)
        self.last_time = lux.time
        self.tweener.update(lux.time - self.last_time)
        
        for p in self.photons:
            p.update(dt, self.photon_speed)
            p.draw()

        ol.color3(1.0, 1.0, 1.0);
        font = ol.getDefaultFont()
        s = "LASER"
        w = ol.getStringWidth(font, 1.0, s)
        ol.drawString(font, (-w/2,1.1), 1.0, s)

        # Draw the bounding box, with a very small hole in it.
        ol.color3(0.0, 1.0, 0.0);
        ol.begin(ol.LINESTRIP)
        ol.vertex3(( CAVITY_SIZE[0]/2,  0.1, 0.0))
        ol.vertex3(( CAVITY_SIZE[0]/2,  CAVITY_SIZE[1]/2, 0.0))
        ol.vertex3((-CAVITY_SIZE[0]/2,  CAVITY_SIZE[1]/2, 0.0))
        ol.vertex3((-CAVITY_SIZE[0]/2, -CAVITY_SIZE[1]/2, 0.0))
        ol.vertex3(( CAVITY_SIZE[0]/2, -CAVITY_SIZE[1]/2, 0.0))
        ol.vertex3(( CAVITY_SIZE[0]/2,  -0.1, 0.0))
        ol.end()
Beispiel #10
0
    def draw(self):
   
        self.i=self.i+1.0;
        
        #inverse persistence length
        self.thetad=0.25*(1.0+sin(2.0*pi*self.i/2000.0))
    
        #RGB curliness offset
        offset=pi/6.0
    
        #RGB curly-straight cycle frequency
        crlstrt=0.005
    
        #RGB maximum curlyness
        curlmx=0.2
    
        theta0B=curlmx*cos(self.i*crlstrt)
        theta0R=curlmx*cos(self.i*crlstrt+offset)
        theta0G=curlmx*cos(self.i*crlstrt+2.0*offset)
    
        self.thetaB=self.thetaB+random.gauss(theta0B,self.thetad)
        self.thetaR=self.thetaR+random.gauss(theta0R,self.thetad)
        self.thetaG=self.thetaG+random.gauss(theta0G,self.thetad)
    
        self.BX=np.append(self.BX[1:], self.BX[-1]+self.dr*cos(self.thetaB))
        self.BY=np.append(self.BY[1:], self.BY[-1]+self.dr*sin(self.thetaB))
        
        self.RX=np.append(self.RX[1:], self.RX[-1]+self.dr*cos(self.thetaR))
        self.RY=np.append(self.RY[1:], self.RY[-1]+self.dr*sin(self.thetaR))
    
        self.GX=np.append(self.GX[1:], self.GX[-1]+self.dr*cos(self.thetaG))
        self.GY=np.append(self.GY[1:], self.GY[-1]+self.dr*sin(self.thetaG))
         
        # derivative roughness parameter
        # b=0.1;
        # if b != 0.0:
        #     [Fx,Fy]=gradient([self.BX;self.RX;self.GX;self.BY;self.RY;self.GY])
        
        #     self.BX=b*Fx(4,:)+self.BX
        #     self.RX=b*Fx(5,:)+self.RX
        #     self.GX=b*Fx(6,:)+self.GX
        
        #     self.BY=b*Fx(1,:)+self.BY
        #     self.RY=b*Fx(2,:)+self.RY
        #     self.GY=b*Fx(3,:)+self.GY
    
        #combine paths
        rmult=0.0001;
        if 1:
            fmB=0.5
            fmG=0.5
        
            #            self.BX=(self.BX+self.RX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
            self.BX=(self.BX+self.RX)/2.0
            self.BY=(self.BY+self.RY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
        
            self.RX=(self.RX+self.GX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
            self.RY=(self.RY+self.GY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
        
            self.GX=(self.BX+self.GX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
            self.GY=(self.BY+self.GY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
        else:
            fmB=1.0
            fmG=1.0
    
        #spin frequency
        freq=0.01+random.gauss(0,0.002)
    
        self.BX=cos(freq*fmB)*self.BX-sin(freq*fmB)*self.BY
        self.BY=sin(freq*fmB)*self.BX+cos(freq*fmB)*self.BY
    
        self.RX=cos(freq)*self.RX-sin(freq)*self.RY
        self.RY=sin(freq)*self.RX+cos(freq)*self.RY
        
        self.GX=cos(freq*fmG)*self.GX-sin(freq*fmG)*self.GY
        self.GY=sin(freq*fmG)*self.GX+cos(freq*fmG)*self.GY
    
        #centering
        self.BX=self.BX-self.BX.mean()
        self.BY=self.BY-self.BY.mean()
    
        self.RX=self.RX-self.RX.mean()
        self.RY=self.RY-self.RY.mean()
    
        self.GX=self.GX-self.GX.mean()
        self.GY=self.GY-self.GY.mean()
    
        #scaling and bouncy factor
        bounce=5.0
        self.fB  =  self.fB + ((self.fB+max(np.sqrt(self.BX**2+self.BY**2)))/2.0-self.fB)/bounce
        self.fR  =  self.fR + ((self.fR+max(np.sqrt(self.RX**2+self.RY**2)))/2.0-self.fR)/bounce
        self.fG  =  self.fG + ((self.fG+max(np.sqrt(self.GX**2+self.GY**2)))/2.0-self.fG)/bounce
    
        self.BX=self.BX/self.fB
        self.BY=self.BY/self.fB
    
        self.RX=self.RX/self.fR
        self.RY=self.RY/self.fR
        
        self.GX=self.GX/self.fG
        self.GY=self.GY/self.fG    
    
        ####################################
        #LUX RENDERING CODE
        ####################################

        ol.loadIdentity3()
        ol.loadIdentity()
        #        ol.color3(*(self.color_cycle()))
        ol.scale3((self.scale_factor,self.scale_factor,self.scale_factor))
        theta_rot = 0.4*cos(1.7 * lux.time * self.ROT_RATE) + 0.6*cos(0.7 * lux.time * self.ROT_RATE)
        ol.rotate3Z(theta_rot)


        render_type  =  ol.POINTS

        current_hue_marker = self.writhe_current_hue
        current_hue_target = self.writhe_hue_target
        current_hue_step = self.writhe_hue_step
        
#        ol.color3(0.0,0.0,1.0)
        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((self.BX[i], self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((-self.BX[i], self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((self.BX[i], -self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((-self.BX[i], -self.BY[i], -1))
        ol.end()
Beispiel #11
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        ol.color3(1.0, 0.0, 1.0)
        font = ol.getDefaultFont()
        s = "davidad"
        x = sin(lux.time) * 0.5
        w = ol.getStringWidth(font, x, s)
        #ol.drawString(font, (-w/2,0), x, s)

        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        t = lux.time * 2
        lx = 0
        ly = 0
        for i in range(8):

            c = floor(t * 2 + i) % 3
            c = 3
            if (c == 1):
                #if(1):
                ol.color3(1.0, 1.0, 0.0)
            if (c == 2):
                ol.color3(0.0, 1.0, 1.0)
            if (c == 3):
                ol.color3(1.0, 0.0, 1.0)

            ol.scale3((0.6, 0.6, 0.6))
            #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
            #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
            #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

            z = 2 * sin(t * 2)
            z = -1 + 4 * (t * 2 - floor(t * 2))
            #z = 4
            x = 0.5 * sin(t + i / 1.0)
            y = 0.5 * cos(t + i / 1.0)

            ol.begin(ol.LINESTRIP)
            ol.vertex3((x - 1, y - 1, z))
            ol.vertex3((x - 1, y + 1, z))
            ol.vertex3((x + 1, y + 1, z))
            ol.vertex3((x + 1, y - 1, z))
            ol.vertex3((x - 1, y - 1, z))
            ol.end()

            if i != 0:
                ol.begin(ol.LINESTRIP)
                ol.vertex3((x - 1, y - 1, z))
                ol.vertex3((lx - 1, ly - 1, z + 4))
                ol.end()

                ol.begin(ol.LINESTRIP)
                ol.vertex3((x - 1, y + 1, z))
                ol.vertex3((lx - 1, ly + 1, z + 4))
                ol.end()

                ol.begin(ol.LINESTRIP)
                ol.vertex3((x + 1, y + 1, z))
                ol.vertex3((lx + 1, ly + 1, z + 4))
                ol.end()

                ol.begin(ol.LINESTRIP)
                ol.vertex3((x + 1, y - 1, z))
                ol.vertex3((lx + 1, ly - 1, z + 4))
                ol.end()

            lx = x
            ly = y
Beispiel #12
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        #ol.color3(1.0, 0.0, 1.0);
        #font = ol.getDefaultFont()
        #s = "Lux!"
        #w = ol.getStringWidth(font, 0.2, s)
        #ol.drawString(font, (-w/2,0.1), 0.2, s)

        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))


        #Dodecahedron---------------------------
        ol.color3(1.0,1.0,1.0);
        ol.scale3((0.8, 0.8, 0.8))
        ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
        ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
        ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

        for face in self.dodeca_face_edges:
            ol.begin(ol.LINESTRIP)
            ol.vertex3(face[0])
            ol.vertex3(face[1])
            ol.vertex3(face[2])
            ol.vertex3(face[3])
            ol.vertex3(face[4])
            ol.vertex3(face[0])
            ol.end()

        #Icosahedron---------------------------
        ol.color3(1.0,1.0,0.0);
                    
        ol.scale3((0.9, 0.9, 0.9))
        ol.rotate3Z(lux.time * pi * 0.5 * lux.simple_rate)
        #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
        #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

        for face in self.icos_face_edges:
            ol.begin(ol.LINESTRIP)
            ol.vertex3(face[0])
            ol.vertex3(face[1])
            ol.vertex3(face[2])
            ol.vertex3(face[0])
            ol.end()
        #for strip in self.icos_face_edges:
        #    ol.begin(ol.LINESTRIP)
        #    for f in strip:
        #        ol.vertex3(f)
        #    ol.end()

        #Cube---------------------------
#         ol.color3(0.0,0.0,1.0);
#         ol.scale3((0.4, 0.4, 0.4))
#         #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
#         #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
#         ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

#         ol.begin(ol.LINESTRIP)
#         ol.vertex3((-1, -1, -1))
#         ol.vertex3(( 1, -1, -1))
#         ol.vertex3(( 1,  1, -1))
#         ol.vertex3((-1,  1, -1))
#         ol.vertex3((-1, -1, -1))
#         ol.vertex3((-1, -1,  1))
#         ol.end()
        
#         ol.begin(ol.LINESTRIP);
#         ol.vertex3(( 1,  1,  1))
#         ol.vertex3((-1,  1,  1))
#         ol.vertex3((-1, -1,  1))
#         ol.vertex3(( 1, -1,  1))
#         ol.vertex3(( 1,  1,  1))
#         ol.vertex3(( 1,  1, -1))
#         ol.end()
        
#         ol.begin(ol.LINESTRIP)
#         ol.vertex3(( 1, -1, -1))
#         ol.vertex3(( 1, -1,  1))
#         ol.end()
        
#         ol.begin(ol.LINESTRIP)
#         ol.vertex3((-1,  1,  1))
#         ol.vertex3((-1,  1, -1))
#         ol.end()

        #Octahedron------------------------
        ol.color3(0.0,0.0,1.0);
        ol.scale3((.8, .8, .8))
        #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
        ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
        #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

        for strip in self.octahedron_face_edges:
            ol.begin(ol.LINESTRIP)
            for f in strip:
                ol.vertex3(f)
            ol.end()
Beispiel #13
0
	font = ol.getDefaultFont()
	s = "Hi!"
	w = ol.getStringWidth(font, 0.2, s)
	ol.drawString(font, (-w/2,0.1), 0.2, ol.C_WHITE, s)

	ol.perspective(60, 1, 1, 100)
	ol.translate3((0, 0, -3))

	for i in range(2):
		if (i == 1):
                    ol.color3(1.0,0.0,0.0);
                else:
                    ol.color3(0.0,1.0,0.0);

		ol.scale3((0.6, 0.6, 0.6))
		ol.rotate3Z(time * pi * 0.1)
		ol.rotate3X(time * pi * 0.8)
		ol.rotate3Y(time * pi * 0.73)

		ol.begin(ol.LINESTRIP)
		ol.vertex3((-1, -1, -1))
		ol.vertex3(( 1, -1, -1))
		ol.vertex3(( 1,  1, -1))
		ol.vertex3((-1,  1, -1))
		ol.vertex3((-1, -1, -1))
		ol.vertex3((-1, -1,  1))
		ol.end()

		ol.begin(ol.LINESTRIP);
		ol.vertex3(( 1,  1,  1))
Beispiel #14
0
frames = 0

while True:
    ol.loadIdentity3()
    ol.loadIdentity()

    font = ol.getDefaultFont()
    s = "Hi!"
    w = ol.getStringWidth(font, 0.2, s)
    ol.drawString(font, (-w / 2, 0.1), 0.2, ol.C_WHITE, s)

    ol.perspective(60, 1, 1, 100)
    ol.translate3((0, 0, -3))

    for i in range(2):
        ol.scale3((0.6, 0.6, 0.6))
        ol.rotate3Z(time * pi * 0.1)
        ol.rotate3X(time * pi * 0.8)
        ol.rotate3Y(time * pi * 0.73)

        ol.begin(ol.LINESTRIP)
        ol.vertex3((-1, -1, -1), ol.C_WHITE)
        ol.vertex3((1, -1, -1), ol.C_WHITE)
        ol.vertex3((1, 1, -1), ol.C_WHITE)
        ol.vertex3((-1, 1, -1), ol.C_WHITE)
        ol.vertex3((-1, -1, -1), ol.C_WHITE)
        ol.vertex3((-1, -1, 1), ol.C_WHITE)
        ol.end()

        ol.begin(ol.LINESTRIP)
        ol.vertex3((1, 1, 1), ol.C_WHITE)
Beispiel #15
0
    def draw(self):

        self.i = self.i + 1.0

        #inverse persistence length
        self.thetad = 0.25 * (1.0 + sin(2.0 * pi * self.i / 2000.0))

        #RGB curliness offset
        offset = pi / 6.0

        #RGB curly-straight cycle frequency
        crlstrt = 0.005

        #RGB maximum curlyness
        curlmx = 0.2

        theta0B = curlmx * cos(self.i * crlstrt)
        theta0R = curlmx * cos(self.i * crlstrt + offset)
        theta0G = curlmx * cos(self.i * crlstrt + 2.0 * offset)

        self.thetaB = self.thetaB + random.gauss(theta0B, self.thetad)
        self.thetaR = self.thetaR + random.gauss(theta0R, self.thetad)
        self.thetaG = self.thetaG + random.gauss(theta0G, self.thetad)

        self.BX = np.append(self.BX[1:],
                            self.BX[-1] + self.dr * cos(self.thetaB))
        self.BY = np.append(self.BY[1:],
                            self.BY[-1] + self.dr * sin(self.thetaB))

        self.RX = np.append(self.RX[1:],
                            self.RX[-1] + self.dr * cos(self.thetaR))
        self.RY = np.append(self.RY[1:],
                            self.RY[-1] + self.dr * sin(self.thetaR))

        self.GX = np.append(self.GX[1:],
                            self.GX[-1] + self.dr * cos(self.thetaG))
        self.GY = np.append(self.GY[1:],
                            self.GY[-1] + self.dr * sin(self.thetaG))

        # derivative roughness parameter
        # b=0.1;
        # if b != 0.0:
        #     [Fx,Fy]=gradient([self.BX;self.RX;self.GX;self.BY;self.RY;self.GY])

        #     self.BX=b*Fx(4,:)+self.BX
        #     self.RX=b*Fx(5,:)+self.RX
        #     self.GX=b*Fx(6,:)+self.GX

        #     self.BY=b*Fx(1,:)+self.BY
        #     self.RY=b*Fx(2,:)+self.RY
        #     self.GY=b*Fx(3,:)+self.GY

        #combine paths
        rmult = 0.0001
        if 1:
            fmB = 0.5
            fmG = 0.5

            #            self.BX=(self.BX+self.RX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0
            self.BX = (self.BX + self.RX) / 2.0
            self.BY = (self.BY + self.RY +
                       (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0

            self.RX = (self.RX + self.GX +
                       (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0
            self.RY = (self.RY + self.GY +
                       (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0

            self.GX = (self.BX + self.GX +
                       (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0
            self.GY = (self.BY + self.GY +
                       (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0
        else:
            fmB = 1.0
            fmG = 1.0

        #spin frequency
        freq = 0.01 + random.gauss(0, 0.002)

        self.BX = cos(freq * fmB) * self.BX - sin(freq * fmB) * self.BY
        self.BY = sin(freq * fmB) * self.BX + cos(freq * fmB) * self.BY

        self.RX = cos(freq) * self.RX - sin(freq) * self.RY
        self.RY = sin(freq) * self.RX + cos(freq) * self.RY

        self.GX = cos(freq * fmG) * self.GX - sin(freq * fmG) * self.GY
        self.GY = sin(freq * fmG) * self.GX + cos(freq * fmG) * self.GY

        #centering
        self.BX = self.BX - self.BX.mean()
        self.BY = self.BY - self.BY.mean()

        self.RX = self.RX - self.RX.mean()
        self.RY = self.RY - self.RY.mean()

        self.GX = self.GX - self.GX.mean()
        self.GY = self.GY - self.GY.mean()

        #scaling and bouncy factor
        bounce = 5.0
        self.fB = self.fB + (
            (self.fB + max(np.sqrt(self.BX**2 + self.BY**2))) / 2.0 -
            self.fB) / bounce
        self.fR = self.fR + (
            (self.fR + max(np.sqrt(self.RX**2 + self.RY**2))) / 2.0 -
            self.fR) / bounce
        self.fG = self.fG + (
            (self.fG + max(np.sqrt(self.GX**2 + self.GY**2))) / 2.0 -
            self.fG) / bounce

        self.BX = self.BX / self.fB
        self.BY = self.BY / self.fB

        self.RX = self.RX / self.fR
        self.RY = self.RY / self.fR

        self.GX = self.GX / self.fG
        self.GY = self.GY / self.fG

        ####################################
        #LUX RENDERING CODE
        ####################################

        ol.loadIdentity3()
        ol.loadIdentity()
        #        ol.color3(*(self.color_cycle()))
        ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor))
        theta_rot = 0.4 * cos(1.7 * lux.time * self.ROT_RATE) + 0.6 * cos(
            0.7 * lux.time * self.ROT_RATE)
        ol.rotate3Z(theta_rot)

        render_type = ol.POINTS

        current_hue_marker = self.writhe_current_hue
        current_hue_target = self.writhe_hue_target
        current_hue_step = self.writhe_hue_step

        #        ol.color3(0.0,0.0,1.0)
        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((self.BX[i], self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((-self.BX[i], self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((self.BX[i], -self.BY[i], -1))
        ol.end()

        self.writhe_current_hue = current_hue_marker
        self.writhe_current_target = current_hue_target
        self.writhe_current_step = current_hue_step

        ol.begin(ol.POINTS)
        for i in range(self.BX.shape[0]):
            ol.color3(*(self.writhe_color_cycle()))
            ol.vertex3((-self.BX[i], -self.BY[i], -1))
        ol.end()
Beispiel #16
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        ol.color3(1.0, 0.0, 1.0);
        font = ol.getDefaultFont()
        s = "davidad"
	x = sin(lux.time)*0.5;
        w = ol.getStringWidth(font, x, s)
        #ol.drawString(font, (-w/2,0), x, s)

        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        t = lux.time*2
        lx = 0
        ly = 0
        for i in range(8):

            c = floor(t*2+i)%3
            c = 3
            if (c==1):
	    #if(1):
                ol.color3(1.0,1.0,0.0);
            if (c==2):
                ol.color3(0.0,1.0,1.0);
            if (c==3):
                ol.color3(1.0,0.0,1.0);
                    
            ol.scale3((0.6, 0.6, 0.6))
            #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate)
            #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate)
            #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate)

	    z = 2*sin(t*2)
            z = -1+4*(t*2-floor(t*2))
            #z = 4
            x = 0.5*sin(t+i/1.0);
            y = 0.5*cos(t+i/1.0);

            ol.begin(ol.LINESTRIP)
            ol.vertex3((x-1,y-1,z))
            ol.vertex3((x-1,y+1,z))
            ol.vertex3((x+1,y+1,z))
            ol.vertex3((x+1,y-1,z))
            ol.vertex3((x-1,y-1,z))
            ol.end()

            if i != 0:
                ol.begin(ol.LINESTRIP)
                ol.vertex3((x-1,y-1,z))
                ol.vertex3((lx-1,ly-1,z+4))
                ol.end()
            
                ol.begin(ol.LINESTRIP)
                ol.vertex3((x-1,y+1,z))
                ol.vertex3((lx-1,ly+1,z+4))
                ol.end()
            
                ol.begin(ol.LINESTRIP)
                ol.vertex3((x+1,y+1,z))
                ol.vertex3((lx+1,ly+1,z+4))
                ol.end()
            
                ol.begin(ol.LINESTRIP)
                ol.vertex3((x+1,y-1,z))
                ol.vertex3((lx+1,ly-1,z+4))
                ol.end()

            lx = x
            ly = y