示例#1
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            # Choose a new random location for the eyes to travers to

            next = [list(self.cm.p_eye_pos), list(self.cm.b_eye_pos)]

            # Since intensified ranges -1 to +1, we need to convert it into 0 to 1.0
            abs_intensity = (self.cm.intensified + 1.0) / 2.0

            max_tilt = abs_intensity * 40.0
            max_pan = abs_intensity * 130.0

            self.last = self.next
            self.next = [
                [
                    next[0][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[0][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ],
                [
                    next[1][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[1][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ]
            ]

            # Make sure the new target is reasonable so that the next next frame isn't starting
            # from a totally insane place
            self.next[0][0] = clamp(self.next[0][0], -270.0, 270.0)
            self.next[1][0] = clamp(self.next[1][0], -270.0, 270.0)
            self.next[0][1] = clamp(self.next[0][1], -135.0, 135.0)
            self.next[1][1] = clamp(self.next[1][1], -135.0, 135.0)

            #print "ai=%f last=%s  new=%s" % (abs_intensity, str(self.last), str(self.next))

        self.pe.pan = self.last[0][0] + (
            (self.last[0][0] - self.next[0][0]) * progress)
        self.pe.tilt = self.last[0][1] + (
            (self.last[0][1] - self.next[0][1]) * progress)
        self.pe.color_pos = self.cm.chosen_colors_pos[0]

        self.be.pan = self.last[1][0] + (
            (self.last[1][0] - self.next[1][0]) * progress)
        self.be.tilt = self.last[1][1] + (
            (self.last[1][1] - self.next[1][1]) * progress)
        self.be.color_pos = self.cm.chosen_colors_pos[1]

        self.pe.effect = self.effect
        self.be.effect = self.effect
示例#2
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            # Choose a new random location for the eyes to travers to

            next = [list(self.cm.p_eye_pos), list(self.cm.b_eye_pos)]

            # Since intensified ranges -1 to +1, we need to convert it into 0 to 1.0
            abs_intensity = (self.cm.intensified + 1.0) / 2.0

            max_tilt = abs_intensity * 40.0
            max_pan = abs_intensity * 130.0

            self.last = self.next
            self.next = [
                [
                    next[0][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[0][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ],
                [
                    next[1][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[1][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ]
            ]

            # Make sure the new target is reasonable so that the next next frame isn't starting
            # from a totally insane place
            self.next[0][0] = clamp(self.next[0][0], -270.0, 270.0)
            self.next[1][0] = clamp(self.next[1][0], -270.0, 270.0)
            self.next[0][1] = clamp(self.next[0][1], -135.0, 135.0)
            self.next[1][1] = clamp(self.next[1][1], -135.0, 135.0)

            #print "ai=%f last=%s  new=%s" % (abs_intensity, str(self.last), str(self.next))

        self.pe.pan = self.last[0][0] + (
            (self.last[0][0] - self.next[0][0]) * progress)
        self.pe.tilt = self.last[0][1] + (
            (self.last[0][1] - self.next[0][1]) * progress)
        self.pe.color_pos = self.cm.chosen_colors_pos[0]

        self.be.pan = self.last[1][0] + (
            (self.last[1][0] - self.next[1][0]) * progress)
        self.be.tilt = self.last[1][1] + (
            (self.last[1][1] - self.next[1][1]) * progress)
        self.be.color_pos = self.cm.chosen_colors_pos[1]

        self.pe.effect = self.effect
        self.be.effect = self.effect
示例#3
0
    def set_modifier(self, mIx, new_val):
        mIx = color.clamp(mIx, 0, len(self.modifiers))

        if self.modifiers[mIx] == new_val:
            return

        self.modifiers[mIx] = new_val
        self._notify_modifiers_changed()
示例#4
0
 def tilt(self, val):
     if val is None:
         return
     self._tilt = clamp(float(val), -135.0, 135.0)
示例#5
0
 def pan(self, val):
     if val is None:
         return
     self._pan = clamp(float(val), -270.0, 270.0)
示例#6
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            # Choose a new random location for the eyes to travers to

            next = [list(self.cm.p_eye_pos), list(self.cm.b_eye_pos)]

            # Since intensified ranges -1 to +1, we need to convert it into 0 to 1.0
            abs_intensity = (self.cm.intensified + 1.0) / 2.0

            max_tilt = abs_intensity * 40.0
            max_pan = abs_intensity * 130.0

            self.last = self.next
            self.next = [
                [ 
                    next[0][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[0][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ] , [
                    next[1][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[1][1] + (random.uniform(-1.0, 1.0) * max_tilt)
                ]
            ]

            # Make sure the new target is reasonable so that the next next frame isn't starting
            # from a totally insane place
            self.next[0][0] = clamp(self.next[0][0], -270.0, 270.0)
            self.next[1][0] = clamp(self.next[1][0], -270.0, 270.0)
            self.next[0][1] = clamp(self.next[0][1], -135.0, 135.0)
            self.next[1][1] = clamp(self.next[1][1], -135.0, 135.0)

            print "ai=%f last=%s  new=%s" % (abs_intensity, str(self.last), str(self.next))

            # Choose some random things for different beats
            max_dimmer = 0.5 + (self.cm.intensified * 0.5)
            self.dimmer_vals = [
                random.uniform(0.25, max_dimmer),
                random.uniform(0.0, max_dimmer),
                random.uniform(0.0, max_dimmer),
                random.uniform(0.0, max_dimmer)
            ]

            # Get 4 values out of intensified, and then use this to determine how frequently
            # we are going to change the effect amongst the predefined ones
            x, effect_multi = math.modf(abs_intensity / 0.125)
            effect_multi = 8 - int(effect_multi)
            next_effect_at = self.last_effect_at + (2 * effect_multi)

            if loop_instance >= next_effect_at:
                # Choose one this time though
                self.last_effect_at = loop_instance
                self.effect = random.choice(self.cm.effects)

                if random.uniform(0, 1.0) < abs_intensity:
                    # Change the color pos, but only by 1 
                    self.pe.color_pos += 7
                    if self.pe.color_pos > 127:
                        self.pe.color_pos -= 127
                    print "-- New color = %d" % self.pe.color_pos
                

                print "Effect is now %s" % str(self.effect)
                print "Next effect at %d (now=%d)" % (next_effect_at, loop_instance)


        if not self.cm.modifiers[4]:
            # Beacon mode
            self.be.clear()

            # Position the eyes straight up
            self.be.pan = 0
            self.be.tilt = -90

            # Make 'em pink
            self.be.color_pos = eyes.EYE_COLOR_LAVENDER

            if loop_instance % 2 == 0:
                # Every so often, we make them strope
                self.beaconStrobe.shutter_speed = 1.0 - progress
                self.be.effect = self.beaconStrobe

        else:
            # Lazy eyes mode

            self.be.pan = self.last[1][0] + ((self.last[1][0] - self.next[1][0]) * progress)
            self.be.tilt = self.last[1][1] + ((self.last[1][1] - self.next[1][1]) * progress)
            self.be.color_pos = self.cm.chosen_colors_pos[0]

            self.be.effect = self.effect



        # For pe we keep it on the disco ball
        self.pe.pan = config.get("eye_positions")["disco"][0][0]
        self.pe.tilt = config.get("eye_positions")["disco"][0][1]

        f, beat = math.modf(progress / 0.25)

        self.pe.dimmer = self.dimmer_vals[int(beat)]
示例#7
0
    def increment_step_modifier(self, mIx):
        mIx = color.clamp(mIx, 0, len(self.step_modifiers))

        self.step_modifiers[mIx] += 1

        self._notify_step_modifiers_changed()
示例#8
0
    def toggle_modifier(self, mIx):
        mIx = color.clamp(mIx, 0, len(self.modifiers))

        self.modifiers[mIx] = not self.modifiers[mIx]

        self._notify_modifiers_changed()
示例#9
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            # Choose a new random location for the eyes to travers to

            next = [list(self.cm.p_eye_pos), list(self.cm.b_eye_pos)]

            # Since intensified ranges -1 to +1, we need to convert it into 0 to 1.0
            abs_intensity = (self.cm.intensified + 1.0) / 2.0

            max_tilt = abs_intensity * 40.0
            max_pan = abs_intensity * 130.0

            self.last = self.next
            self.next = [
                [
                    next[0][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[0][1] + (random.uniform(-1.0, 1.0) * max_tilt),
                ],
                [
                    next[1][0] + (random.uniform(-1.0, 1.0) * max_pan),
                    next[1][1] + (random.uniform(-1.0, 1.0) * max_tilt),
                ],
            ]

            # Make sure the new target is reasonable so that the next next frame isn't starting
            # from a totally insane place
            self.next[0][0] = clamp(self.next[0][0], -270.0, 270.0)
            self.next[1][0] = clamp(self.next[1][0], -270.0, 270.0)
            self.next[0][1] = clamp(self.next[0][1], -135.0, 135.0)
            self.next[1][1] = clamp(self.next[1][1], -135.0, 135.0)

            print "ai=%f last=%s  new=%s" % (abs_intensity, str(self.last), str(self.next))

            # Choose some random things for different beats
            max_dimmer = 0.5 + (self.cm.intensified * 0.5)
            self.dimmer_vals = [
                random.uniform(0.25, max_dimmer),
                random.uniform(0.0, max_dimmer),
                random.uniform(0.0, max_dimmer),
                random.uniform(0.0, max_dimmer),
            ]

            # Get 4 values out of intensified, and then use this to determine how frequently
            # we are going to change the effect amongst the predefined ones
            x, effect_multi = math.modf(abs_intensity / 0.125)
            effect_multi = 8 - int(effect_multi)
            next_effect_at = self.last_effect_at + (2 * effect_multi)

            if loop_instance >= next_effect_at:
                # Choose one this time though
                self.last_effect_at = loop_instance
                self.effect = random.choice(self.cm.effects)

                if random.uniform(0, 1.0) < abs_intensity:
                    # Change the color pos, but only by 1
                    self.pe.color_pos += 7
                    if self.pe.color_pos > 127:
                        self.pe.color_pos -= 127
                    print "-- New color = %d" % self.pe.color_pos

                print "Effect is now %s" % str(self.effect)
                print "Next effect at %d (now=%d)" % (next_effect_at, loop_instance)

        if not self.cm.modifiers[4]:
            # Beacon mode
            self.be.clear()

            # Position the eyes straight up
            self.be.pan = 0
            self.be.tilt = -90

            # Make 'em pink
            self.be.color_pos = eyes.EYE_COLOR_LAVENDER

            if loop_instance % 2 == 0:
                # Every so often, we make them strope
                self.beaconStrobe.shutter_speed = 1.0 - progress
                self.be.effect = self.beaconStrobe

        else:
            # Lazy eyes mode

            self.be.pan = self.last[1][0] + ((self.last[1][0] - self.next[1][0]) * progress)
            self.be.tilt = self.last[1][1] + ((self.last[1][1] - self.next[1][1]) * progress)
            self.be.color_pos = self.cm.chosen_colors_pos[0]

            self.be.effect = self.effect

        # For pe we keep it on the disco ball
        self.pe.pan = config.get("eye_positions")["disco"][0][0]
        self.pe.tilt = config.get("eye_positions")["disco"][0][1]

        f, beat = math.modf(progress / 0.25)

        self.pe.dimmer = self.dimmer_vals[int(beat)]
示例#10
0
 def tilt(self, val):
     if val is None:
         return
     self._tilt = clamp(float(val), -135.0, 135.0)
示例#11
0
 def pan(self, val):
     if val is None:
         return
     self._pan = clamp(float(val), -270.0, 270.0)