Esempio n. 1
0
    def __call__(self, tree):
        active = set()
        satStep = 1.0 / self.fade
        color = randomColor()
        hue = color.hue
        tree.fill(color)
        while True:
            # Increase saturation of everything that's on
            deleteMe = []
            for ss, ii in active:
                color = tree[ss][ii].toHsv()
                sat = color.sat + satStep
                if sat > 1.0:
                    deleteMe.append((ss, ii))
                else:
                    tree[ss][ii] = HSV(hue, sat, 1.0)
            for key in deleteMe:
                active.remove(key)
            gc.collect()

            # Add a new one
            string = int(randFloat() * len(tree))
            index = int(randFloat() * len(tree[string]))
            key = (string, index)
            if key in active:
                continue
            active.add(key)
            tree[string][index] = HSV(hue, 0.0, 1.0)
            yield
Esempio n. 2
0
    def __call__(self, tree):
        active = set()
        dimStep = 1.0 / self.fade
        while True:
            # Fade everything that's on
            deleteMe = []
            for ss, ii in active:
                color = tree[ss][ii].toHsv()
                color.dimmer(dimStep)
                if color.value == 0:
                    deleteMe.append((ss, ii))
                else:
                    tree[ss][ii] = color
            for key in deleteMe:
                active.remove(key)
            gc.collect()

            # Add a new one
            string = int(randFloat() * len(tree))
            index = int(randFloat() * len(tree[string]))
            key = (string, index)
            if key in active:
                continue
            active.add(key)
            tree[string][index] = randomColor()
            yield
Esempio n. 3
0
 def __call__(self, tree):
     index = 0
     while True:
         tree.down()
         tree[index]["TOP"] = randomColor()
         index += 1
         if index >= len(tree):
             index = 0
         yield
Esempio n. 4
0
 def __call__(self, tree):
     while True:
         tree.set("TOP", randomColor().toRgb())
         yield
         for _ in range(tree.length - 1):
             tree.down()
             yield
         for _ in range(tree.length - 1):
             tree.up()
             yield
Esempio n. 5
0
 def __call__(self, tree):
     while True:
         color = randomColor()
         for _ in range(self.num):
             for ii in range(tree.length - 1):
                 tree.set(ii, color)
                 tree.set(tree.length - 1 - ii, color)
                 yield
                 tree.set(ii, BLACK)
                 tree.set(tree.length - 1 - ii, BLACK)
Esempio n. 6
0
 def __call__(self, tree):
     while True:
         tree.fill(BLACK)
         color = randomColor().toRgb()
         for ring in range(tree.length):
             for ii in range(tree.length - ring - 1):
                 tree.set(tree.length - 1 - ii, color)
                 yield
                 tree.set(tree.length - 1 - ii, BLACK)
             tree.set(ring, color)
             yield
         for ring in range(tree.length):
             for ii in range(1, ring + 1):
                 tree.set(ring - ii, color)
                 yield
                 tree.set(ring - ii, BLACK)
Esempio n. 7
0
 def __call__(self, tree):
     numStrings = len(tree)
     length = tree.length
     trailEnd = 2 * self.length
     probThreshold = 1.0 / numStrings
     location = np.ones(numStrings, dtype=int) * length  # Location of trail
     colors = [None] * numStrings  # Color of trail
     while True:
         tree.down()
         location += 1
         for ii, string in enumerate(tree):
             if location[ii] <= self.length:
                 # Propagate a trail
                 string["TOP"] = colors[ii]
             elif location[ii] > trailEnd and randFloat() < probThreshold:
                 # Start a trail
                 location[ii] = 0
                 colors[ii] = randomColor()
         yield
Esempio n. 8
0
 def __call__(self, tree):
     num = sum(len(ss) for ss in tree)
     indices = np.zeros((num, 2), dtype=int)
     start = 0
     for ii in range(len(tree)):
         length = len(tree[ii])
         ss = slice(start, start + length)
         indices[ss, 0] = ii
         indices[ss, 1] = np.arange(length)
         start += length
     while True:
         tree.clear()
         order = sorted([(randFloat(), ii) for ii in range(num)])
         for _, ii in order:
             ss, tt = indices[ii]
             tree[ss][tt] = randomColor()
             yield
         for _, ii in order:
             ss, tt = indices[ii]
             tree[ss][tt] = BLACK
             yield
Esempio n. 9
0
 def __call__(self, tree):
     while True:
         tree.down()
         for string in tree:
             string["TOP"] = randomColor()
         yield