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

        ol.loadIdentity3()
        ol.perspective(20, 1, 1, 100)
        ol.translate3((0, 0, -20))

        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)

        for row in self.torender:
            ol.begin(ol.LINESTRIP)
            vi = self.faces[row]
            vi = vi + [vi[0]]

            for i in vi:
                tup = tuple(self.verts[i, :])
                ol.vertex3(tup)

            ol.end()
예제 #2
0
    def draw(self, target):
        x, y =target[0]-self.x, target[1]-self.y

        # point each segment to it's predecessor
        for segment in self.segments:
            dx = x - segment.x
            dy = y - segment.y
            angle = math.atan2(dy, dx)
            segment.angle = angle

            x = x - math.cos(angle) * arm_length/parts
            y = y - math.sin(angle) * arm_length/parts

        # and now move the pointed nodes, starting from the last one
        # (that is the beginning of the arm)
        for prev, segment in reversed(list(zip(self.segments, self.segments[1:]))):
            prev.x = segment.x + math.cos(segment.angle) * arm_length/parts
            prev.y = segment.y + math.sin(segment.angle) * arm_length/parts
            segment.prev_x = prev.x
            segment.prev_y = prev.y

        ol.translate3((self.x, self.y, 0))
        ol.begin(ol.LINESTRIP)
	for segment in self.segments:
            segment.draw(self.color)
	ol.end()
예제 #3
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()
예제 #4
0
    def draw(self, target):
        x, y = target[0] - self.x, target[1] - self.y

        # point each segment to it's predecessor
        for segment in self.segments:
            dx = x - segment.x
            dy = y - segment.y
            angle = math.atan2(dy, dx)
            segment.angle = angle

            x = x - math.cos(angle) * arm_length / parts
            y = y - math.sin(angle) * arm_length / parts

        # and now move the pointed nodes, starting from the last one
        # (that is the beginning of the arm)
        for prev, segment in reversed(list(zip(self.segments, self.segments[1:]))):
            prev.x = segment.x + math.cos(segment.angle) * arm_length / parts
            prev.y = segment.y + math.sin(segment.angle) * arm_length / parts
            segment.prev_x = prev.x
            segment.prev_y = prev.y

        ol.translate3((self.x, self.y, 0))
        ol.begin(ol.LINESTRIP)
        for segment in self.segments:
            segment.draw(self.color)
        ol.end()
예제 #5
0
파일: mesh.py 프로젝트: GunioRobot/Fiat-Lux
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        ol.loadIdentity3()
        ol.perspective(20, 1, 1, 100)
        ol.translate3((0, 0, -20))

        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)
        

        for row in self.torender:
            ol.begin(ol.LINESTRIP)
            vi = self.faces[row]
            vi = vi + [vi[0]]

            for i in vi:
                tup = tuple(self.verts[i,:])
                ol.vertex3(tup)
            
            ol.end()
예제 #6
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)
예제 #7
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()
예제 #8
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

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

        ol.color3(1.0, 1.0, 1.0)

        offset = cos(lux.time * 10)
        ol.begin(ol.LINESTRIP)
        npts = 25
        #ol.scale3((0.5,0.5,0.5))
        for i in range(npts):
            ol.color3(
                float(i) / npts, 1.0 - float(i) / npts,
                (float(i) / npts + (1.0 - float(i) / npts)) / 2.0)
            offset = 0
            mod = (i % 2 * 2.0 - 1.0) * 0.99
            #ol.scale3((mod, mod, mod))
            ol.rotate3Z(lux.time * pi * 0.01 * lux.simple_rate)
            ol.vertex3((float(i) / (npts / 2.0) - 1.0 + offset, -1.0, -1))
            ol.vertex3((float(i) / (npts / 2.0) - 1.0 + offset, 1.0, -1))

        ol.end()
예제 #9
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)
예제 #10
0
    def draw(self):
        time = lux.time
        #time = self.time
        ctf = self.color_time_frequency
        clf = self.color_length_frequency
        caf = self.color_angle_frequency/2
        theta = abs(math.sin(time*self.time_scale))
        R = self.R * math.sin(2*pi*time*self.time_scale*self.R_frequency)
        r = self.r * math.sin(2*pi*time*self.time_scale*self.r_frequency)
        p = self.p * math.sin(2*pi*time*self.time_scale*self.p_frequency) * self.bass

        ol.color3(1.0, 0.0, 1.0);
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))
        
        first = True
        n = 0
        while theta < 2*pi*self.max_cycles and n < self.max_segments:
            theta += self.theta_step
            #x = (R + r) * math.cos(theta)
            #y = (R + r) * math.sin(theta)
            x = (R + r) * math.cos(theta) + (r + p) * math.cos((R+r)/r * theta)
            y = (R + r) * math.sin(theta) + (r + p) * math.sin((R+r)/r * theta)
            
            if first:
                ol.begin(ol.LINESTRIP)
                #ol.begin(ol.POINTS)
                first = False
            #red = math.sin(ctf*time*n/37) * math.sin(csf*theta*n/37)
            #green = math.sin(ctf*time*n/23) * math.sin(csf*theta*n/23)
            #blue = math.sin(ctf*time*n/128) * math.sin(csf*theta*n/128)
            
            angle = math.atan2(y, x)/(2*pi)
            red   = abs(math.sin(2*pi*(self.r_prime/3+ctf*time+clf*n+caf*angle)))
            green = abs(math.sin(2*pi*(self.g_prime/3+ctf*time+clf*n+caf*angle)))
            blue =  abs(math.sin(2*pi*(self.b_prime/3+ctf*time+clf*n+caf*angle)))
            ol.color3(red, green, blue)
            
            #this makes it square-ish
            #x += math.cos(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            #y += math.sin(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            x += math.cos(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude
            y += math.sin(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude


            x *= self.width
            y *= self.height
            ol.vertex3((x,y,0))
            n += 1
        ol.end()
        #dynamically adjust resolution
        target = self.max_segments * 0.8
        error = (target - n)/target
        self.theta_step = min(max(1e-100, self.theta_step * (1-error)), 1)
        #print n,  angle
        self.time += 1/30
예제 #11
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.color3(0.0, 1.0, 1.0);
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        #target_x, target_y = random.uniform(-1, 1), random.uniform(-1, 1)
        target_x, target_y = math.sin(2*pi*swoosh_frequency*lux.time*3), math.sin(2*pi*swoosh_frequency*lux.time*5)
        #target_x, target_y = math.tan(2*pi*swoosh_frequency*lux.time*3), math.sin(2*pi*swoosh_frequency*lux.time*5)
        for arm in self.arms: arm.draw([target_x, target_y])
예제 #12
0
    def draw(self):
        ol.loadIdentity()
        ol.rotate(lux.time / 10)

        # Grab the raw audio buffer
        mono = audio_engine.mono_buffer()

        # Make sure it ain't empty!!
        if mono.shape[0] == 0:
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if mono.shape[0] > 10000:
            audio_engine.clear_all()

        ol.color3(*(self.color_cycle()))
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        if (lux.time > self.nextSnapshot):
            #print "snapshot"
            self.nextSnapshot = lux.time + self.interval
            self.currentWave = self.nextWave
            self.nextWave = zeros(shape=(self.renderPointCount))
            # load in new values
            for i in range(int(self.renderPointCount - 1)):
                self.nextWave[i] = mono[i * self.skip] * 2

        # draw shape
        fracIntervalComplete = (
            lux.time - (self.nextSnapshot - self.interval)) / self.interval
        #        print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot)
        coordsToRender = zeros(shape=(self.renderPointCount, 2))
        firstVal = None
        for i in range(int(self.renderPointCount - 1)):
            val = ((self.nextWave[i] - self.currentWave[i]) *
                   fracIntervalComplete) + self.currentWave[i]
            if (firstVal is None): firstVal = val
            #print "next: %f  curr:  %f   frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete)
            (x, y) = self.doTheTrigStuff(
                val, (float(i) / float(self.renderPointCount)), firstVal)
            coordsToRender[i][0] = x
            coordsToRender[i][1] = y
        coordsToRender[self.renderPointCount - 1] = coordsToRender[0]

        # render shape
        ol.begin(ol.LINESTRIP)
        for i in range(0, int(self.renderPointCount), 1):
            #            print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1])
            ol.vertex((coordsToRender[i][0], coordsToRender[i][1]))
        ol.end()
        ol.vertex((coordsToRender[0][0], coordsToRender[0][1]))
예제 #13
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()
예제 #14
0
파일: bouncyball.py 프로젝트: fenn/Fiat-Lux
    def draw(self):
        ol.loadIdentity()

        ol.rotate(lux.time / 10)

        # Grab the raw audio buffer
        mono = audio_engine.mono_buffer()

        # Make sure it ain't empty!!
        if mono.shape[0] == 0:
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if mono.shape[0] > 10000:
            audio_engine.clear_all()
            return

        ol.color3(*(self.color_cycle()))
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        if lux.time > self.nextSnapshot:
            # print "snapshot"
            self.nextSnapshot = lux.time + self.interval
            self.currentWave = self.nextWave
            self.nextWave = zeros(shape=(self.renderPointCount))
            # load in new values
            for i in range(self.renderPointCount - 1):
                self.nextWave[i] = mono[i * self.skip]

        # draw shape
        fracIntervalComplete = (lux.time - (self.nextSnapshot - self.interval)) / self.interval
        #        print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot)
        coordsToRender = zeros(shape=(self.renderPointCount, 2))
        firstVal = None
        for i in range(self.renderPointCount - 1):
            val = ((self.nextWave[i] - self.currentWave[i]) * fracIntervalComplete) + self.currentWave[i]
            if firstVal is None:
                firstVal = val
            # print "next: %f  curr:  %f   frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete)
            (x, y) = self.doTheTrigStuff(val, (float(i) / float(self.renderPointCount)), firstVal)
            coordsToRender[i][0] = x
            coordsToRender[i][1] = y
        coordsToRender[self.renderPointCount - 1] = coordsToRender[0]

        # render shape
        ol.begin(ol.LINESTRIP)
        for i in range(self.renderPointCount):
            #            print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1])
            ol.vertex((coordsToRender[i][0], coordsToRender[i][1]))
        ol.end()
예제 #15
0
    def draw(self):
        '''a square'''
        #self.x = math.cos(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale
        #self.y = math.sin(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale
        
        #stolen from guilloche
        time = lux.time * time_scale 
        R = math.sin(2*pi*self.R_frequency*time) * self.R + 0.0001
        r = math.sin(2*pi*self.r_frequency*time) * self.r + 0.0001
        p = math.sin(2*pi*self.p_frequency*time) * self.p + 0.0001
        self.x = (R + r) * math.cos(time) + (r + p) * math.cos((R+r)/r * time) 
        self.y = (R + r) * math.sin(time) + (r + p) * math.sin((R+r)/r * time) 
        
        #clamp to display area
        if clamp_display:
            if self.x > 1: self.x = 1
            if self.y > 1: self.y = 1
            if self.x < -1: self.x = -1
            if self.y < -1: self.y = -1
        self.x *= scale
        self.y *= scale
        #self.graphics.circle(0, 0, self.radius)
        ol.loadIdentity3()
        ol.loadIdentity()


        #ol.color3(self.color[0], self.color[1], self.color[2])
        ol.color3(self.red, self.green, self.blue)
        ol.translate3((self.x, self.y, 0))
        angle = math.atan2(self.y, self.x)/(2*pi)
        red   = abs(math.sin(2*pi*(r_prime/3+ctf*time+clf*self.n+caf*angle)))*self.red
        green = abs(math.sin(2*pi*(g_prime/3+ctf*time+clf*self.n+caf*angle)))*self.green
        blue =  abs(math.sin(2*pi*(b_prime/3+ctf*time+clf*self.n+caf*angle)))*self.blue
        if seizure_mode:
          #red, green, blue = red/self.radius, green/self.radius, blue/self.radius
          red = abs(red*math.tan((2*pi*self.radius/node_big_radius)))
          green = abs(green*math.tan((2*pi*self.radius/node_big_radius)))
          blue = abs(blue*math.tan((2*pi*self.radius/node_big_radius)))
        
        ol.color3(red, green, blue)
 
        #do squares have radii?
        s = self.radius
        ol.begin(ol.POINTS)
        ol.vertex3((-s, s,0))
        ol.vertex3((-s, s,0))
        ol.vertex3(( s, s,0))
        ol.vertex3(( s,-s,0))
        ol.vertex3((-s,-s,0))
        ol.end()
예제 #16
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.color3(0.0, 1.0, 1.0)
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        # target_x, target_y = random.uniform(-1, 1), random.uniform(-1, 1)
        target_x, target_y = (
            math.sin(2 * pi * swoosh_frequency * lux.time * 3),
            math.sin(2 * pi * swoosh_frequency * lux.time * 5),
        )
        # target_x, target_y = math.tan(2*pi*swoosh_frequency*lux.time*3), math.sin(2*pi*swoosh_frequency*lux.time*5)
        for arm in self.arms:
            arm.draw([target_x, target_y])
예제 #17
0
    def draw(self, val):
        '''a square'''
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.color3(self.color[0], self.color[1], self.color[2])
        ol.translate3((self.x, self.y, 0))
        ol.begin(ol.POINTS)
        ol.vertex3((.0, .0, .0))
        ol.vertex3((.0, .1, .0))
        ol.vertex3((.1, .1, .0))
        ol.vertex3((.1, .0, .0))
        ol.vertex3((.0, .0, .0))
        ol.end()

        self.moving = True
        return self
예제 #18
0
  def draw(self, val):
    '''a square'''
    ol.loadIdentity3()
    ol.loadIdentity()
    ol.color3(self.color[0], self.color[1], self.color[2])
    ol.translate3((self.x, self.y, 0))
    ol.begin(ol.POINTS)
    ol.vertex3((.0,.0,.0))
    ol.vertex3((.0,.1,.0))
    ol.vertex3((.1,.1,.0))
    ol.vertex3((.1,.0,.0))
    ol.vertex3((.0,.0,.0))
    ol.end()

    self.moving = True
    return self
예제 #19
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        #        dt = lux.time - self.last_time

        self.net.draw()
        foo = self.tweener.update(lux.time * time_scale - self.last_time)

        #print list(foo)
        #bar = list(foo)[0]

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

        self.last_time = lux.time * time_scale
예제 #20
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()
        
#        dt = lux.time - self.last_time

        self.net.draw()
        foo= self.tweener.update(lux.time*time_scale - self.last_time)
        
        #print list(foo)
        #bar = list(foo)[0]

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

        self.last_time = lux.time * time_scale
예제 #21
0
    def draw(self):
        time = lux.time
        ctf = self.color_time_frequency
        clf = self.color_length_frequency
        caf = self.color_angle_frequency/2
        theta0 = abs(math.sin(time*self.time_scale))

        
        for braid_count in range(1,self.NUM_CIRCLES):
            first = True
            n = 0
            theta = theta0
            
            ol.color3(1.0, 0.0, 1.0);
            ol.loadIdentity3()
            ol.loadIdentity()
            ol.perspective(40, 1, 1, 100)
            ol.translate3((0, 0, -3))
            ol.rotate3Z(lux.time * pi * self.z_rotations[braid_count])
            ol.rotate3X(lux.time * pi * self.x_rotations[braid_count])
            ol.rotate3Z(lux.time * pi * self.x_rotations[braid_count])

            ol.begin(ol.LINESTRIP)
            while theta < theta0 + 2*pi:

                r = (0.5+sin(10*theta)/2.0) / float(braid_count) * self.scale
                x = r * cos(theta)
                y = r * sin(theta)

                angle = math.atan2(y, x)/(2*pi)
                red   = abs(math.sin(2*pi*(self.r_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count]))
                green = abs(math.sin(2*pi*(self.g_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count]))
                blue =  abs(math.sin(2*pi*(self.b_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count]))
                ol.color3(red, green, blue)
                ol.vertex3((x,y,0))
                n += 1

                theta += 1.0/float(self.max_segments)

            r = (0.5+sin(10*theta)/2.0) / float(braid_count) * self.scale
            x = r * cos(theta)
            y = r * sin(theta)
            ol.vertex3((x,y,0))  # Close the path
            ol.end()
예제 #22
0
    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()
예제 #23
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)
                
예제 #24
0
    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()
예제 #25
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        if not self.particle.moving and self.particle.wait > 0.5:
            self.particle.wait = 0
            self.bounce()

#        dt = lux.time - self.last_time
        self.particle.wait += lux.time - self.last_time

        self.chain.draw(target=(self.particle.x, self.particle.y))
        foo = self.tweener.update(lux.time - self.last_time)

        #print list(foo)
        #bar = list(foo)[0]

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

        self.last_time = lux.time
예제 #26
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()
        
        if not self.particle.moving and self.particle.wait > 0.5:
          self.particle.wait = 0
          self.bounce()

#        dt = lux.time - self.last_time
        self.particle.wait += lux.time - self.last_time

        self.chain.draw(target=(self.particle.x, self.particle.y))
        foo= self.tweener.update(lux.time - self.last_time)
        
        #print list(foo)
        #bar = list(foo)[0]

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

        self.last_time = lux.time
예제 #27
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

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

        ol.color3(1.0,1.0,1.0)

        offset = cos(lux.time*10)
        ol.begin(ol.LINESTRIP)
        npts = 25
        #ol.scale3((0.5,0.5,0.5))
        for i in range(npts):
            ol.color3(float(i)/npts,1.0-float(i)/npts,(float(i)/npts+(1.0-float(i)/npts))/2.0)
            offset = 0
            mod = (i%2 * 2.0 - 1.0) * 0.99
            #ol.scale3((mod, mod, mod))
            ol.rotate3Z(lux.time * pi * 0.01 * lux.simple_rate)
            ol.vertex3((float(i)/(npts/2.0)-1.0+offset,-1.0,-1))
            ol.vertex3((float(i)/(npts/2.0)-1.0+offset,1.0,-1))

        ol.end()
예제 #28
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()
예제 #29
0
파일: two_cubes.py 프로젝트: fenn/Fiat-Lux
    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()
예제 #30
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
예제 #31
0
    def run(self):

        # Run the render loop.  This will repeatedly render frames of the current plugin.
        print '\t--> Starting up LUX Engine.'
        ftime = 0
        frames = 0

        # Initialize OpenLase.  This also creates the lux_engine jack endpoints.
        if (ol.init(3, 96000) != 0):
            raise Exception("Could not initialize openlase")

        # Connect the output engine to the lux_engine.
        self.output_engine.connect_ports("lux_engine:out_x", "lux_output:in_x")
        self.output_engine.connect_ports("lux_engine:out_y", "lux_output:in_y")
        self.output_engine.connect_ports("lux_engine:out_r", "lux_output:in_r")
        self.output_engine.connect_ports("lux_engine:out_g", "lux_output:in_g")
        self.output_engine.connect_ports("lux_engine:out_b", "lux_output:in_b")

        # Turn off the hardware safety interlock.
        self.output_engine.setOutputInitialized(True)

        # Create a local settings object for this thread.
        settings = LuxSettings()

        while not self.exiting:
            # Grab local references to these class variables
            self.lock.lock()
            current_plugin = self.current_plugin
            video_engine = self.video_engine
            self.lock.unlock()

            # SET PARAMETERS
            #
            # Check to see if the GUI parameter override has been set,
            # and we need to update OL parameters.
            if (self.ol_update_params
                    and settings['calibration'].parameterOverride
                    and current_plugin):
                current_plugin.setParametersToGuiValues()
                self.ol_update_params = False

            if (current_plugin
                    and not settings['calibration'].parameterOverride):
                current_plugin.setParameters()

            if (self.reset_plugin_on_next_frame):
                current_plugin.reset()
                self.reset_plugin_on_next_frame = False

            # RENDER
            #
            # We call out to the current plugin's draw() method, or
            # the video plugin, depending on the current state of the
            # GUI.
            if (current_plugin):
                if (settings['video'].videoMode):
                    # Cause video color cycling to happen
                    ol.loadIdentity3()
                    ol.loadIdentity()
                    ol.perspective(60, 1, 1, 100)
                    ol.translate3((0, 0, -3))

                    ol.color3(*(self.video_color_drift.color_cycle()))
                    video_engine.draw_lasers()
                else:
                    current_plugin.draw()

                frame_render_time = ol.renderFrame(
                    60)  # Takes max_fps as argument
                frames += 1
                ftime += frame_render_time
                #print "Frame time: %f, FPS:%f"%(frame_render_time, frame_render_time/ftime)
            else:
                # If there is no plugin for some reason, kill time
                # rather than burning CPU in a loop that does nothing.
                time.sleep(0.1)
예제 #32
0
    def draw(self, audio):
        '''a square'''
        #self.x = math.cos(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale
        #self.y = math.sin(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale

        #stolen from guilloche
        time = lux.time * time_scale
        R = math.sin(2 * pi * self.R_frequency * time) * self.R + 0.0001
        r = math.sin(2 * pi * self.r_frequency * time) * self.r + 0.0001
        p = math.sin(2 * pi * self.p_frequency * time) * self.p + 0.0001
        self.x = (R + r) * math.cos(time) + (r + p) * math.cos(
            (R + r) / r * time)
        self.y = (R + r) * math.sin(time) + (r + p) * math.sin(
            (R + r) / r * time)

        #clamp to display area
        if clamp_display:
            if self.x > 1: self.x = 1
            if self.y > 1: self.y = 1
            if self.x < -1: self.x = -1
            if self.y < -1: self.y = -1
        self.x *= scale
        self.y *= scale
        #self.graphics.circle(0, 0, self.radius)
        ol.loadIdentity3()
        ol.loadIdentity()

        #ol.color3(self.color[0], self.color[1], self.color[2])
        ol.color3(self.red, self.green, self.blue)
        ol.translate3((self.x, self.y, 0))
        angle = math.atan2(self.y, self.x) / (2 * pi)
        red = self.red  #abs(math.sin(2*pi*(r_prime/3+ctf*time+clf*self.n+caf*angle)))*self.red
        green = abs(
            math.sin(2 * pi * (g_prime / 3 + ctf * time + clf * self.n +
                               caf * angle))) * self.green
        blue = abs(
            math.sin(2 * pi * (b_prime / 3 + ctf * time + clf * self.n +
                               caf * angle))) * self.blue
        if seizure_mode:
            #red, green, blue = red/self.radius, green/self.radius, blue/self.radius
            red = abs(red * math.tan((2 * pi * self.radius / node_big_radius)))
            green = abs(green * math.tan(
                (2 * pi * self.radius / node_big_radius)))
            blue = abs(blue * math.tan(
                (2 * pi * self.radius / node_big_radius)))
        if audio:
            try:
                #seems most of the time all the samples are empty
                #sample_index = int((self.n/max_nodes)*audio[0].shape[0])
                sample_index = 0  #self.n
                sample = audio[0][n]

            except:
                sample = 1
        else:
            sample = 1  #[0 for x in range(10000)] #empty vector
        #print sample
        if audio:
            red = red
            blue = blue + sample * self.audio_gain
            green = green + sample * self.audio_gain
        ol.color3(red, green, blue)
        if self.last_sample - sample > 0.1:
            pass  #pulse
        #do squares have radii?
        s = self.radius
        ol.begin(ol.POINTS)
        ol.vertex3((-s, s, 0))
        ol.vertex3((-s, s, 0))
        ol.vertex3((s, s, 0))
        ol.vertex3((s, -s, 0))
        ol.vertex3((-s, -s, 0))
        ol.end()
예제 #33
0
    def run(self):

        # Run the render loop.  This will repeatedly render frames of the current plugin.
        print '\t--> Starting up LUX Engine.'
        ftime = 0
        frames = 0

        # Initialize OpenLase.  This also creates the lux_engine jack endpoints.
        if (ol.init(3, 96000) != 0):
            raise Exception("Could not initialize openlase")

        # Connect the output engine to the lux_engine.
        self.output_engine.connect_ports("lux_engine:out_x", "lux_output:in_x")
        self.output_engine.connect_ports("lux_engine:out_y", "lux_output:in_y")
        self.output_engine.connect_ports("lux_engine:out_r", "lux_output:in_r")
        self.output_engine.connect_ports("lux_engine:out_g", "lux_output:in_g")
        self.output_engine.connect_ports("lux_engine:out_b", "lux_output:in_b")

        # Turn off the hardware safety interlock.
        self.output_engine.setOutputInitialized(True)

        # Create a local settings object for this thread.
        settings = LuxSettings()
        
        while not self.exiting:
            # Grab local references to these class variables
            self.lock.lock()
            current_plugin = self.current_plugin
            video_engine = self.video_engine
            self.lock.unlock()
            
            # SET PARAMETERS
            #
            # Check to see if the GUI parameter override has been set,
            # and we need to update OL parameters.
            if (self.ol_update_params and settings['calibration'].parameterOverride and current_plugin):
                current_plugin.setParametersToGuiValues()
                self.ol_update_params = False

            if (current_plugin and not settings['calibration'].parameterOverride):
                current_plugin.setParameters();

            # RENDER
            #
            # We call out to the current plugin's draw() method, or
            # the video plugin, depending on the current state of the
            # GUI.
            if (current_plugin):
                if (settings['video'].videoMode):
                    # Cause video color cycling to happen
                    ol.loadIdentity3();
                    ol.loadIdentity();
                    ol.perspective(60, 1, 1, 100);
                    ol.translate3((0, 0, -3));

                    ol.color3(*(self.video_color_drift.color_cycle()))
                    video_engine.draw_lasers()
                else:
                    current_plugin.draw()

                frame_render_time = ol.renderFrame(60)   # Takes max_fps as argument
                frames += 1
                ftime += frame_render_time
                #print "Frame time: %f, FPS:%f"%(frame_render_time, frame_render_time/ftime)
            else:
                # If there is no plugin for some reason, kill time
                # rather than burning CPU in a loop that does nothing.
                time.sleep(0.1)
예제 #34
0
    def draw(self):
        time = lux.time
        #time = self.time
        ctf = self.color_time_frequency
        clf = self.color_length_frequency
        caf = self.color_angle_frequency / 2
        theta = abs(math.sin(time * self.time_scale))
        R = self.R * math.sin(
            2 * pi * time * self.time_scale * self.R_frequency)
        r = self.r * math.sin(
            2 * pi * time * self.time_scale * self.r_frequency)
        p = self.p * math.sin(
            2 * pi * time * self.time_scale * self.p_frequency) * self.bass
        audio = self.get_audio()

        ol.color3(1.0, 0.0, 1.0)
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        first = True
        n = 0
        while theta < 2 * pi * self.max_cycles and n < self.max_segments:
            theta += self.theta_step
            if audio:
                try:
                    sample_index = int(
                        theta / (2 * pi * self.max_cycles) *
                        (audio[0].shape[0] - 1)) + 1  #skip first sample
                    sample = audio[2][sample_index]
                except:
                    sample = 0
            else:
                sample = 0  #[0 for x in range(10000)] #empty vector
            #x = (R + r) * math.cos(theta)
            #y = (R + r) * math.sin(theta)
            sample *= self.audio_gain
            #print sample
            #x = (R + r) * math.cos(theta) + (r + p + sample) * math.cos((R+r)/r * theta)
            #y = (R + r) * math.sin(theta) + (r + p + sample) * math.sin((R+r)/r * theta)
            #ben's ill advised DALT change
            x = (R + r) * math.cos(theta) + (r + p * sample) * math.cos(
                (R + r) / r * theta)
            y = (R + r) * math.sin(theta) + (r + p * sample) * math.sin(
                (R + r) / r * theta)

            if first:
                #ol.begin(ol.LINESTRIP)
                ol.begin(ol.POINTS)
                first = False
            #red = math.sin(ctf*time*n/37) * math.sin(csf*theta*n/37)
            #green = math.sin(ctf*time*n/23) * math.sin(csf*theta*n/23)
            #blue = math.sin(ctf*time*n/128) * math.sin(csf*theta*n/128)

            angle = math.atan2(y, x) / (2 * pi)
            red = abs(
                math.sin(
                    2 * pi *
                    (self.r_prime / 3 + ctf * time + clf * n + caf * angle)))
            green = abs(
                math.sin(
                    2 * pi *
                    (self.g_prime / 3 + ctf * time + clf * n + caf * angle)))
            blue = abs(
                math.sin(
                    2 * pi *
                    (self.b_prime / 3 + ctf * time + clf * n + caf * angle)))
            ol.color3(red, green, blue)

            #this makes it square-ish
            #x += math.cos(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            #y += math.sin(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            x += math.cos(2 * pi * angle * (self.spatial_resonance + 1) +
                          2 * pi * self.spatial_resonance_offset
                          ) * self.spatial_resonance_amplitude
            y += math.sin(2 * pi * angle * (self.spatial_resonance + 1) +
                          2 * pi * self.spatial_resonance_offset
                          ) * self.spatial_resonance_amplitude

            x *= self.width
            y *= self.height
            ol.vertex3((x, y, 0))
            n += 1
        ol.end()
        #dynamically adjust resolution
        target = self.max_segments * 0.8
        error = (target - n) / target
        self.theta_step = min(max(1e-100, self.theta_step * (1 - error)), 1)
        #print n,  angle
        self.time += 1 / 30
예제 #35
0
    def draw(self):
        time = lux.time
        #time = self.time
        ctf = self.color_time_frequency
        clf = self.color_length_frequency
        caf = self.color_angle_frequency/2
        theta = abs(math.sin(time*self.time_scale))
        R = self.R * math.sin(2*pi*time*self.time_scale*self.R_frequency)
        r = self.r * math.sin(2*pi*time*self.time_scale*self.r_frequency)
        p = self.p * math.sin(2*pi*time*self.time_scale*self.p_frequency) * self.bass
        audio = self.get_audio()

        ol.color3(1.0, 0.0, 1.0);
        ol.loadIdentity3()
        ol.loadIdentity()
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))
        
        first = True
        n = 0
        while theta < 2*pi*self.max_cycles and n < self.max_segments:
            theta += self.theta_step
            if audio:
                try:
                  sample_index = int(theta/(2*pi*self.max_cycles)*(audio[0].shape[0]-1))+1 #skip first sample
                  sample = audio[2][sample_index]
                except: sample = 0
            else: sample = 0 #[0 for x in range(10000)] #empty vector
            #x = (R + r) * math.cos(theta)
            #y = (R + r) * math.sin(theta)
            sample *= self.audio_gain
		#print sample
            #x = (R + r) * math.cos(theta) + (r + p + sample) * math.cos((R+r)/r * theta)
            #y = (R + r) * math.sin(theta) + (r + p + sample) * math.sin((R+r)/r * theta)
            #ben's ill advised DALT change
	    x = (R + r) * math.cos(theta) + (r + p * sample) * math.cos((R+r)/r * theta)
            y = (R + r) * math.sin(theta) + (r + p * sample) * math.sin((R+r)/r * theta)
            
            if first:
                #ol.begin(ol.LINESTRIP)
                ol.begin(ol.POINTS)
                first = False
            #red = math.sin(ctf*time*n/37) * math.sin(csf*theta*n/37)
            #green = math.sin(ctf*time*n/23) * math.sin(csf*theta*n/23)
            #blue = math.sin(ctf*time*n/128) * math.sin(csf*theta*n/128)
            
            angle = math.atan2(y, x)/(2*pi)
            red   = abs(math.sin(2*pi*(self.r_prime/3+ctf*time+clf*n+caf*angle)))
            green = abs(math.sin(2*pi*(self.g_prime/3+ctf*time+clf*n+caf*angle)))
            blue =  abs(math.sin(2*pi*(self.b_prime/3+ctf*time+clf*n+caf*angle)))
            ol.color3(red, green, blue)
            
            #this makes it square-ish
            #x += math.cos(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            #y += math.sin(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude
            x += math.cos(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude
            y += math.sin(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude


            x *= self.width
            y *= self.height
            ol.vertex3((x,y,0))
            n += 1
        ol.end()
        #dynamically adjust resolution
        target = self.max_segments * 0.8
        error = (target - n)/target
        self.theta_step = min(max(1e-100, self.theta_step * (1-error)), 1)
        #print n,  angle
        self.time += 1/30
예제 #36
0
ol.init()

time = 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):
		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))
예제 #37
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
예제 #38
0
    def draw(self, audio):
        '''a square'''
        #self.x = math.cos(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale
        #self.y = math.sin(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale
        
        #stolen from guilloche
        time = lux.time * time_scale 
        R = math.sin(2*pi*self.R_frequency*time) * self.R + 0.0001
        r = math.sin(2*pi*self.r_frequency*time) * self.r + 0.0001
        p = math.sin(2*pi*self.p_frequency*time) * self.p + 0.0001
        self.x = (R + r) * math.cos(time) + (r + p) * math.cos((R+r)/r * time) 
        self.y = (R + r) * math.sin(time) + (r + p) * math.sin((R+r)/r * time) 
        
        #clamp to display area
        if clamp_display:
            if self.x > 1: self.x = 1
            if self.y > 1: self.y = 1
            if self.x < -1: self.x = -1
            if self.y < -1: self.y = -1
        self.x *= scale
        self.y *= scale
        #self.graphics.circle(0, 0, self.radius)
        ol.loadIdentity3()
        ol.loadIdentity()


        #ol.color3(self.color[0], self.color[1], self.color[2])
        ol.color3(self.red, self.green, self.blue)
        ol.translate3((self.x, self.y, 0))
        angle = math.atan2(self.y, self.x)/(2*pi)
        red   = self.red #abs(math.sin(2*pi*(r_prime/3+ctf*time+clf*self.n+caf*angle)))*self.red
        green = abs(math.sin(2*pi*(g_prime/3+ctf*time+clf*self.n+caf*angle)))*self.green
        blue =  abs(math.sin(2*pi*(b_prime/3+ctf*time+clf*self.n+caf*angle)))*self.blue
        if seizure_mode:
          #red, green, blue = red/self.radius, green/self.radius, blue/self.radius
          red = abs(red*math.tan((2*pi*self.radius/node_big_radius)))
          green = abs(green*math.tan((2*pi*self.radius/node_big_radius)))
          blue = abs(blue*math.tan((2*pi*self.radius/node_big_radius)))
        if audio:   
                try:
                  #seems most of the time all the samples are empty
		  #sample_index = int((self.n/max_nodes)*audio[0].shape[0])
                  sample_index = 0 #self.n
	          sample = audio[0][n]

                except: sample = 1
        else: sample = 1 #[0 for x in range(10000)] #empty vector 
        #print sample 
        if audio:
          red = red
          blue = blue + sample*self.audio_gain
          green = green + sample*self.audio_gain
        ol.color3(red, green, blue)
	if self.last_sample - sample > 0.1:
          pass #pulse 
        #do squares have radii?
        s = self.radius
        ol.begin(ol.POINTS)
        ol.vertex3((-s, s,0))
        ol.vertex3((-s, s,0))
        ol.vertex3(( s, s,0))
        ol.vertex3(( s,-s,0))
        ol.vertex3((-s,-s,0))
        ol.end()
예제 #39
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()
예제 #40
0
ol.init()

time = 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()