Beispiel #1
0
    def beacon_shader(self,p):

        # use progress
        if self.show:
            color_hsv = rgb_to_hsv(self.color)  

            if self.all:
                dist_x = 1-abs(p['point'][0])
                dist_y = 1-abs(p['point'][1])
                dist_z = 1-abs(p['point'][2])
                if dist_x < 0.02:
                    return hsv (color_hsv[0], color_hsv[1], 1-dist_x)
                if dist_y < 0.02: 
                    return hsv (color_hsv[0], color_hsv[1], 1-dist_y)
                if dist_z < 0.2:
                    return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
                return (0,0,0)

            else:
                dist = abs(p['point'][2]-1)
                if dist > 0.1:
                    dist=1
                return hsv (color_hsv[0], color_hsv[1], 1-dist)
        else: 
            return (0,0,0)
Beispiel #2
0
    def next_frame(self):

        self.tri_grid.clear()
        time.sleep(3)

        while True:
            self.ca = hsv(0.0, 0.0, 0.0)
            self.cb = hsv1(0.0, 0.0, 0.0)
            while self.ca.v < 1.0:
                self.ca.v += 0.0008
                self.tri_grid.set_all_cells(self.ca)
                self.tri_grid.go()
                time.sleep(.01)
                print('CA', self.ca.hsv)

            while self.ca.s < 1.0:
                self.ca.s += 0.0008
                self.tri_grid.set_all_cells(self.ca)
                self.tri_grid.go()
                time.sleep(.01)
                print('CA', self.ca.hsv)

            while self.ca.h < 1.0:
                self.ca.h += 0.0008
                self.tri_grid.set_all_cells(self.ca)
                self.tri_grid.go()
                time.sleep(.01)
                print('CA', self.ca.hsv)

            self.tri_grid.clear()
            time.sleep(3)

            while self.cb.v < 1.0:
                self.cb.v += 0.0008
                self.tri_grid.set_all_cells(self.cb)
                self.tri_grid.go()
                time.sleep(.01)
                print('CB', self.cb.hsv)

            while self.cb.s < 1.0:
                self.cb.s += 0.0008
                self.tri_grid.set_all_cells(self.cb)
                self.tri_grid.go()
                time.sleep(.01)
                print('CB', self.cb.hsv)

            while self.cb.h < 1.0:
                self.cb.h += 0.0008
                self.tri_grid.set_all_cells(self.cb)
                self.tri_grid.go()
                time.sleep(.01)
                print('CB', self.cb.hsv)

            self.tri_grid.clear()
            self.tri_grid.set_all_cells(hsv(1.0, 1.0, 1.0))
            time.sleep(3)
            self.tri_grid.clear()

            yield self.frame_delay
Beispiel #3
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        # now = 0.002 * time.time() * 1000     # millis
        now = 0.002 * time.time() * 1000     # millis

        particles = []
        rand = random.random() * 0.005
        for i in range(self.numParticles):
            s = float(i) / self.numParticles

            #radius = 0.2 + 1.5 * s
            radius = 0.2 + 1.5 * s
            theta = now + 0.04 * i
            x = radius * cos(theta)
            y = radius * sin(theta + 10.0 * sin(theta * 0.15))
            hue = (now * 0.01 + s * 0.2) % 1 

            self.z += rand * self.sign
            if self.z > 0.9: 
                self.z=0.9
                self.sign = -1
            if self.z < -0.8: 
                self.z=-0.8
                self.sign = 1

            # 'intensity': 0.2 * s,
            particles.append({
                "point": [x, y, self.z],
                'intensity': s * 0.7,
                'falloff': 60,
                'color': hsv(hue, 0.8, 0.9)
            })

        self._particles = particles
Beispiel #4
0
    def shader(self, p):
        x = p['point'][0]
        y = p['point'][1]
        #z = p['point'][2] 
        z = p['point'][2] + 1

        distx = x - self.centerx
        disty = y - self.centery
        distz = z - self.centerz

        dist = sqrt(distx**2 + disty**2 + distz**2)
        pulse = (sin(self.dz + dist * self.spacing) - 0.3) * 0.3
      
        n = Rings.fractalNoise(
            x * self.scale + self.dx + pulse,
            y * self.scale,
            z * self.scale + self.dz,
            self.dw
        ) - 0.95

        m = Rings.fractalNoise(
            x * self.scale + self.dx,
            y * self.scale,
            z * self.scale + self.dz,
            self.dw  + 10.0
        ) - 0.75

        # TBD: abs(n) is my doing, was just n
        return hsv(
            (self.hue + 0.2 * m) %1,
            self.saturation,
            min(max(pow(3.0 * abs(n), 1.5), 0), 0.9)
        )
Beispiel #5
0
    def shader(self,p):

        x = p['point'][0] 
        y = p['point'][1]
        z = p['point'][2]

        x_ = x*cos(self.angle)-y*sin(self.angle)
        y_ = x*sin(self.angle)+y*cos(self.angle)

        col = rgb_to_hsv(self.flag)

        if (abs(x_)<0.3 and abs(z)<0.6 and y_>0):
            return hsv(col[0], col[1], 1-abs(x_))
            #return hsv(0.3, 0, 1-abs(x_))
        if (abs(z)<0.2 and abs(x_)<0.6 and y_>0):
            return hsv(col[0], col[1], 1-abs(z))
            #return hsv(0.3, 0, 1-abs(z))

        # background
        return self.background
Beispiel #6
0
    def update_at_progress(self, progress, new_loop, loop_instance):

	(loud, pitch) = self.audio.audio_input()
        color = col.hsv(pitch,pitch,loud)
        #color = col.hsv(0.5,1,loud)

        # draw
        for i in range(self.geometry.get_nof_pixels()):
            self.geometry.set_pixel(i, color)

        self.geometry.draw()
Beispiel #7
0
    def shader(self, p):

        x = p['point'][0]
        dist_x = abs(x - self.dx)   # trail - small is large tail

        if dist_x < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            dist_x = dist_x / self.trail

            return hsv (color_hsv[0], color_hsv[1], 1-dist_x)
        else:
            return self.background
Beispiel #8
0
    def shader(self, p):

        z = p['point'][2]
        dist_z = abs(z - self.dz)  

        if dist_z < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            dist_z = dist_z / self.trail
    
            return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
            
        else:
            return self.background
Beispiel #9
0
    def shader(self, p):

        x = p['point'][0]
        y = p['point'][1]
        z = p['point'][2]
     
        x_rot = x
        # y_rot = y                   # will hold the rotated variables

        # moving packman - we need to rotate x and y
        if self.move:
            rotate = self.progress * 2*pi   # mouth opens 4 times and one
                                            # progress is one revolution
                                            # map to circle

            x_rot = x * cos(rotate) - y * sin(rotate)           
            #y_rot = y * cos(rotate) + x * sin(rotate)

        # This is PacMan, believe it or not, well, almost
        # y_ = 1 - x_rot**2 - z**2
        z_ = tan(self.angle) * x_rot

        # Learning: The perfect math does not always create the best visual representation
        # and cheating is more fun and faster too ;)

        if x_rot < 0: return self.color     # the non-mouth half of pacman
        #if y_ < abs(y_rot) and z_ < abs(z):
        if z_ < abs(z):
            color_hsv = rgb_to_hsv(self.color)  
            # -- dist = ((x_rot-x)**2 + (y_rot-y_)**2 + (z-z_)**2)  * 4
            # working: dist = ((y_rot-y_)**2 + (z-z_)**2)  * 4
            dist = abs(z-z_)
            intensity = 1
            if dist < 0.1:
                #intensity = 10*dist
                intensity = 10*dist
            #if dist > 1: dist = 1
            # intensity = cos(dist)
            return hsv (color_hsv[0], color_hsv[1], intensity)
        else:
            return self.background
Beispiel #10
0
    def rotate_x_shader(self, p):

        y = p['point'][1]
        x = p['point'][0]


        # the shape itself
        z_ = y*sin(self.angle)+z*cos(self.angle)

        # don't change the z-position
        dist_z = abs(z_)  
        
        if dist_z < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            dist_z = dist_z / self.trail
    
            return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
            
        else:
            return self.background
Beispiel #11
0
    def shader(self, p):

        z = p['point'][2]
        y = p['point'][1]
        x = p['point'][0]

        # shape tilt
        x_ = x*cos(self.tilt)-z*sin(self.tilt)
        z_ = z*sin(self.tilt)+x*cos(self.tilt)
        y_ = y

        # rotate
        x__ = x_
        y__ = y_*cos(self.angle)-z_*sin(self.angle)
        z__ = y_*sin(self.angle)+z_*cos(self.angle)

        self.dz = 0
        dist_z = abs(z__ - self.dz)  
        

        #dist_z = abs(z_ - self.dz)  
        #dist = sqrt((z_-z) ** 2 + (y_-y) ** 2 + (x_-x) ** 2)
        #dist_2 = sqrt((z_-z) **2 + (y_-y) **2)

        #if (abs(x_)<0.3 and abs(y_)<0.6 and y_>0):
        #if (abs(x_)<self.trail and abs(y_)<self.trail and abs(z_)<self.trail):

        #if dist_z < self.trail and dist_y < self.trail:
        if dist_z < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            dist_z = dist_z / self.trail
    
            #return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
            return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
            
        else:
            return self.background
Beispiel #12
0
    def Testing_shader(self, p):

        x = p['point'][0]
        y = p['point'][1]
        z = p['point'][2]
        #print 's', self.z

        x_ = cos(self.theta) * sin(self.phi)
        y_ = cos(self.theta) * cos(self.phi)
        z_ = sin(self.theta)
        dist = sqrt((z_-z) ** 2 + (y_-y) ** 2 + (x_-x) ** 2)

        if dist < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            #return hsv (color_hsv[0], color_hsv[1], 1.0-dist*1/self.trail)
            dist = dist / self.trail
            intensity = 1-dist
            # intensity = cos(dist)
            return hsv (color_hsv[0], color_hsv[1], intensity)

        else:
            return self.background
Beispiel #13
0
    def shader_rotate_y(self, p):

        z = p['point'][2]
        y = p['point'][1]
        x = p['point'][0]

        # shape tilt
        z_ = z*sin(self.tilt)+x*cos(self.tilt)
        y_ = y

        # rotate
        z__ = y_*sin(self.angle)+z_*cos(self.angle)

        dist_z = abs(z__)  
        
        if dist_z < self.trail:

            color_hsv = rgb_to_hsv(self.color)  # set the intesity to the distance
            dist_z = dist_z / self.trail
    
            return hsv (color_hsv[0], color_hsv[1], 1-dist_z)
            
        else:
            return self.background
Beispiel #14
0
 def test_hsv_KnownValues(self):
     """ color.hsv() should give known output for known input"""
     for integer, hsv_color, rgb_color in self.knownValues:
         output = color.hsv(integer, k=self.k, fase=self.fase)
         self.assertEqual(hsv_color, output)
Beispiel #15
0
	def test_hsv_KnownValues(self):
		""" color.hsv() should give known output for known input"""
		for integer, hsv_color, rgb_color in self.knownValues:
			output = color.hsv(integer, k=self.k, fase=self.fase)
			self.assertEqual(hsv_color, output)