Ejemplo n.º 1
0
    def update(self, cm, base_hue, mode, progress):
        if progress < self.last_progress:
            self.last_progress = progress

        delta_progress = progress - self.last_progress

        self.last_progress = progress

        # These half factors are calmer
        factor = 0.5
        if cm.modifiers[4]:
            factor = 0.25

        # Decay our energy by some rate
        if self.state == "increasing":
            self.energy += delta_progress * 7.0 * factor
            if self.energy >= 1.0:
                self.energy = 1.0
                self.state = "decreasing"

        elif self.state == "decreasing":
            amt = 1.0
            if cm:
                amt = factor * 5.0 * (1.0 + cm.intensified) / 2.0
            self.energy -= delta_progress * amt

            if self.energy <= 0.0:
                self.energy = 0.0
                self.state = "neutral"

        clr = geom.BLACK

        v = 0.25 + (self.energy * 0.75)

        if mode == 0:
            # Everything as white
            clr = color.HSV(base_hue, self.energy, v)
            self.cells.set_cells(self.bird, clr)

            # Eyes as red
            clr = color.HSV(0.0, 1.0, v)
            self.cells.set_cell(self.bird[0], clr)
            self.cells.set_cell(self.bird[59], clr)

            # Wingtips???

        elif mode == 1:
            # Everything as hue
            clr = color.HSV(self.hue, self.energy, v)
            self.cells.set_cells(self.bird, clr)

            # Eyes as red
            clr = color.HSV(0.0, 1.0, v)
            self.cells.set_cell(self.bird[0], clr)
            self.cells.set_cell(self.bird[59], clr)
Ejemplo n.º 2
0
    def update(self, cm, mode, progress):
        if progress < self.last_progress:
            self.last_progress = progress

        delta_progress = progress - self.last_progress

        self.last_progress = progress

        # Like calmer factors
        factor = 0.5
        if cm.modifiers[4]:
            factor = 0.25

        # Decay our energy by some rate
        if self.state == "increasing":
            self.energy += delta_progress * 15.0 * factor
            if self.energy >= 1.0:
                self.energy = 1.0
                self.state = "decreasing"

        elif self.state == "decreasing":
            amt = 1.0
            if cm:
                amt = factor * 10.0 * (1.0 + cm.intensified) / 2.0
            self.energy -= delta_progress * amt

            if self.energy <= 0.0:
                self.energy = 0.0
                self.state = "neutral"

        clr = geom.BLACK

        if mode == 0:
            # Just set the fading color
            if self.state != "neutral":
                clr = color.HSV(self.hue, 1.0, self.energy)

            self.cells.set_cells(self.bird, clr)
        elif mode == 1:
            # Set some portion of the cells
            to_blank = int(math.floor((1.0 - self.energy) * 16))

            clr = color.HSV(self.hue, 1.0, 1.0)

            for ix, cell in enumerate(self.bird):
                diff_l = math.fabs(16 - ix)
                diff_r = math.fabs(44 - ix)
                if diff_l <= to_blank or diff_r <= to_blank:
                    self.cells.set_cell(cell, geom.BLACK)
                else:
                    self.cells.set_cell(cell, clr)
Ejemplo n.º 3
0
    def update_at_progress(self, cm, is_new):
        t_prog = 0.0
        b_mod = 0.0
        if self.progress < 0.5:
            # Heading towards max
            t_prog = self.progress * 2
            sat = tween.easeInOutQuad(0, 1.0, t_prog)
            b_mod = tween.easeInOutQuad(0.2, 1.0, t_prog)
        else:
            # Heading from max towards min
            t_prog = (self.progress - 0.5) * 2
            sat = tween.easeInOutQuad(1.0, 0, t_prog)
            b_mod = tween.easeInOutQuad(1.0, 0.2, t_prog)

        if is_new:
            self.hue = 0.0

            if cm.modifiers[0]:
                self.hue = 0.66

            if cm.modifiers[1]:
                self.hue = random.random()

            if cm.modifiers[2]:
                self.hue = master_hue
                # print "Use master_hue self.hue=%s" % self.hue

        b = 1.0
        if cm.modifiers[4]:
            b = b_mod

        c = color.HSV(self.hue, sat, b)
        self.cells.set_cell(self.icicle, c)
Ejemplo n.º 4
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        units = geom.by_faces

        for ix, unit in enumerate(units):
            distance = 0
            l = len(unit) - 1

            for jx, cell_id in enumerate(unit):
                if self.cm.modifiers[1]:
                    # Reverse
                    distance = (float(l-jx) / float(len(unit))) + progress
                else:
                    distance = (float(jx) / float(len(unit))) + progress

                # Clamp
                if distance > 1.0:
                    distance = distance - 1.0
                if distance < 0.0:
                    distance = distance + 1.0

                # Color
                if self.cm.modifiers[0]:
                    clr = color.HSVryb(distance, 1.0, 1.0)
                elif self.cm.modifiers[1]:
                    clr = color.Color(tween.hsvLinear(self.cm.chosen_colors[0], self.cm.chosen_colors[1], distance))
                else:
                    clr = color.HSV(distance, 1.0, 1.0)

                # Set the one cell
                self.ss.party.set_cell(cell_id, clr)
Ejemplo n.º 5
0
    def update_at_progress(self, cm, is_new):
        if self.progress < 0.5:
            # Heading towards max
            t_prog = self.progress * 2
            sat = tween.easeInOutQuad(0, 1.0, t_prog)
        else:
            # Heading from max towards min
            t_prog = (self.progress - 0.5) * 2
            sat = tween.easeInOutQuad(1.0, 0, t_prog)

        c = color.HSV(0.66, sat, 1.0)
        self.cells.set_cells(self.icicle, c)
Ejemplo n.º 6
0
    def update_at_progress(self, cm, is_new):
        hue = self.progress + self.offset
        if hue > 1.0:
            hue -= 1.0

        step = 1.0 / geom.BIRD_SIZE

        for pVal in self.bird:
            clr = color.HSV(hue, 0.5, 1.0)
            self.cells.set_cell(pVal, clr)

            hue += step
            if hue > 1.0:
                hue -= 1.0
Ejemplo n.º 7
0
    def next_frame(self):

        while (True):

            for icicle in ice_geom.ICICLES:
                distance = float(self.count % len(ice_geom.ICICLES)) / len(
                    ice_geom.ICICLES)

                clr = color.HSV(distance, 1.0, 1.0)
                self.cells.set_cells(icicle, clr)
                self.count += 2

            #self.count += 1
            yield self.speed
Ejemplo n.º 8
0
    def next_frame(self):

        while (True):

            _list = geom.HSTRIPES

            for row in _list:
                distance = float(self.count % len(_list)) / len(_list)

                clr = color.HSV(distance, 1.0, 1.0)
                self.cells.set_cells(row, clr)
                self.count += 1

            #self.count += 1
            yield self.speed
Ejemplo n.º 9
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        mode = self.step_mode(self.num_steps)

        # mode 0
        stripes = geom.by_long_planes
        if mode == 1:
            stripes = geom.by_short_planes
        elif mode == 2:
            stripes = geom.by_edges
        elif mode == 3:
            stripes = geom.by_faces
        # elif mode == 4:
        #     stripes = geom.SPIRAL
        # elif mode == 5:
        #     stripes = geom.ICICLES

        l = len(stripes) - 1
        for ix, row in enumerate(stripes):
            distance = 0.0

            if self.cm.modifiers[1]:
                # Reverse
                distance = (float(l - ix) / float(len(stripes))) + progress
            else:
                # Normal progression
                distance = (float(ix) / float(len(stripes))) + progress

            # Clamp
            while distance > 1.0:
                distance = distance - 1.0

            while distance < 0.0:
                distance = distance + 1.0

            if self.cm.modifiers[0]:
                clr = color.HSVryb(distance, 1.0, 1.0)
            elif self.cm.modifiers[1]:
                clr = color.Color(
                    tween.hsvLinear(self.cm.chosen_colors[0],
                                    self.cm.chosen_colors[1], distance))
            else:
                clr = color.HSV(distance, 1.0, 1.0)

            if mode == 4:
                self.ss.both.set_cell(row, clr)
            else:
                self.ss.both.set_cells(row, clr)
Ejemplo n.º 10
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        mode = self.step_mode(2)

        # mode 0
        stripes = geom.BIRDS

        if mode == 1:
            stripes = geom.ATOMS
        # elif mode == 2:
        #     stripes = geom.RINGS
        # elif mode == 3:
        #     stripes = geom.QUADRANTS
        # elif mode == 4:
        #     stripes = geom.SPIRAL
        # elif mode == 5:
        #     stripes = geom.ICICLES


        l = len(stripes) - 1
        for ix, row in enumerate(stripes):
            distance = 0.0

            if self.cm.modifiers[1]:
                # Reverse
                distance = (float(l - ix) / float(len(stripes))) + progress
            else:
                # Normal progression
                distance = (float(ix) / float(len(stripes))) + progress
            
            # Clamp
            while distance > 1.0:
                distance = distance - 1.0

            while distance < 0.0:
                distance = distance + 1.0


            if self.cm.modifiers[0]:
                clr = color.HSVryb(distance, 1.0, 1.0)
            else:
                clr = color.HSV(distance, 1.0, 1.0)

            if mode == 4:
                self.ss.party.set_cell(row, clr)
            else:
                self.ss.party.set_cells(row, clr)            
Ejemplo n.º 11
0
    def update_at_progress(self, cm, is_new):

        hue = (1.0 - self.progress) + self.offset
        if hue > 1.0:
            hue -= 1.0
        if hue < 1.0:
            hue += 1.0

        for (ix, pVal) in enumerate(self.bird):
            if ix < geom.BIRD_SIZE / 2:
                h = hue + (ix * self.hue_step)
            else:
                h = hue + ((geom.BIRD_SIZE - 1 - ix) * self.hue_step)

            while h > 1.0:
                h -= 1.0

            clr = color.HSV(h, self.sats[ix], 1.0)

            self.cells.set_cell(pVal, clr)
Ejemplo n.º 12
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            if self.cm.modifiers[0]:
                self.foreground = self.cm.chosen_colors[0]
                self.background = self.cm.chosen_colors[1]
            else:
                if self.cm.modifiers[1] or (random.randrange(10) > 7) or (
                        not hasattr(self, "foreground")):
                    # Definitely need a new color
                    if random.randrange(10) > 7:
                        # Also reverse direction
                        self.cm.set_modifier(2, not self.cm.modifiers[2])

                    if self.cm.modifiers[4] or (not hasattr(
                            self, "foreground")):
                        # Two totally new colors
                        self.foreground = random_color(luminosity="dark")
                        self.background = self.foreground.copy()
                        if self.background.h < 0.5:
                            self.background.h += 0.5
                        else:
                            self.background.h -= 0.5
                    else:
                        # Keep old foreground
                        self.background = self.foreground
                        self.foreground = random_color(luminosity="dark")

        for ring in geom.RINGS:
            el_size = 1.0 / len(ring)

            # Debug ring 3 only
            # debug = el_size < 0.4
            # if debug:
            #     print

            for ix, el in enumerate(ring):
                partial = 1.0

                el_start = (ix * el_size) + 0.25
                if el_start >= 1.0:
                    el_start -= 1.0
                el_end = ((ix + 1) * el_size) + 0.25
                if el_end > 1.0:
                    el_end -= 1.0

                v = 0.0
                p = progress
                backwards = self.cm.modifiers[2]

                if backwards:
                    p = 1.0 - progress

                mode = self.step_mode(2)

                if mode == 0:
                    # A single edge that sweeps from 0 to full
                    if p >= el_end:
                        v = 1.0
                    elif p > el_start:
                        v = (p - el_start) / el_size
                    # else v stays at 0

                elif mode == 1:
                    # A 0.25 segment
                    v = self.calcV(el_start, el_end, p, 0.25, debug=False)
                    # if debug:
                    #     print "  %0.4f" % v

                clr = color.HSV(
                    *tween.hsvLinear(self.background, self.foreground, v))

                self.ss.party.set_cell(el, clr)