Esempio n. 1
0
def pixel_color(t, coord, ii, n_pixels):
    """Compute the color of a given pixel.

    t: time in seconds since the program started.
    ii: which pixel this is, starting at 0
    coord: the (x, y, z) position of the pixel as a tuple
    n_pixels: the total number of pixels

    Returns an (r, g, b) tuple in the range 0-255

    """
    # make moving stripes for x, y, and z
    x, y, z = coord
    r = color_utils.cos(x, offset=t / 4, period=1, minn=0, maxx=0.7)
    g = color_utils.cos(y, offset=t / 4, period=1, minn=0, maxx=0.7)
    b = color_utils.cos(z, offset=t / 4, period=1, minn=0, maxx=0.7)
    r, g, b = color_utils.contrast((r, g, b), 0.5, 2)

    # make a moving white dot showing the order of the pixels in the layout file
    spark_ii = (t * 80) % n_pixels
    spark_rad = 8
    spark_val = max(0, (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad)
    spark_val = min(1, spark_val * 2)
    r += spark_val
    g += spark_val
    b += spark_val

    # apply gamma curve
    # only do this on live leds, not in the simulator
    # r, g, b = color_utils.gamma((r, g, b), 2.2)

    return (r * 256, g * 256, b * 256)
Esempio n. 2
0
def pixel_color(t, coord, ii, n_pixels):
    """Compute the color of a given pixel.

    t: time in seconds since the program started.
    ii: which pixel this is, starting at 0
    coord: the (x, y, z) position of the pixel as a tuple
    n_pixels: the total number of pixels

    Returns an (r, g, b) tuple in the range 0-255

    """
    # make moving stripes for x, y, and z
    x, y, z = coord
    r = color_utils.cos(x, offset=t / 4, period=1, minn=0, maxx=0.7)
    g = color_utils.cos(y, offset=t / 4, period=1, minn=0, maxx=0.7)
    b = color_utils.cos(z, offset=t / 4, period=1, minn=0, maxx=0.7)
    r, g, b = color_utils.contrast((r, g, b), 0.5, 2)

    # make a moving white dot showing the order of the pixels in the layout file
    spark_ii = (t * 80) % n_pixels
    spark_rad = 8
    spark_val = max(
        0,
        (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad)
    spark_val = min(1, spark_val * 2)
    r += spark_val
    g += spark_val
    b += spark_val

    # apply gamma curve
    # only do this on live leds, not in the simulator
    #r, g, b = color_utils.gamma((r, g, b), 2.2)

    return (r * 256, g * 256, b * 256)
Esempio n. 3
0
File: swg.py Progetto: Swaeg/madness
def pixel_color(time, coord, ii, n_pixels):
    """Compute the color of a given pixel.

    t: time in seconds since the program started.
    ii: which pixel this is, starting at 0
    coord: the (x, y, z) position of the pixel as a tuple
    n_pixels: the total number of pixels

    Returns an (r, g, b) tuple in the range 0-255

    """
    # make moving stripes for x, y, and z
    x, y, z = coord

    r = color_utils.cos(z, offset=time * 0.1, period=5, minn=0, maxx=0.7)

    g = color_utils.cos(z, offset=time * 0.2, period=2.5, minn=0, maxx=0.7)

    b = color_utils.cos(x, offset=time * 0.1, period=10, minn=0, maxx=0.7)

    r, g, b = color_utils.contrast((r, g, b), 0.1, 2)

    # make a moving white dot showing the order of the pixels in the layout file
    spark_ii = (time * 60) % n_pixels
    spark_rad = 10
    spark_val = max(
        0,
        (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad)
    spark_val = min(1, spark_val * 64)
    #r += spark_val
    g += spark_val
    b += spark_val

    if ii % 10:
        if g > 0.3:
            b += spark_val
        else:
            g += spark_val

    else:
        if g < 0.3:
            b += spark_val
            r -= spark_val
        else:
            b = 0

    #print ii
    #

    if ii > 60 and ii < 120:
        r, g, b = 100

    # apply gamma curve
    # only do this on live leds, not in the simulator
    #r, g, b = color_utils.gamma((r, g, b), 2.2)

    return (r * 256, g * 256, b * 256)
Esempio n. 4
0
File: swg.py Progetto: Swaeg/madness
def pixel_color(time, coord, ii, n_pixels):
    """Compute the color of a given pixel.

    t: time in seconds since the program started.
    ii: which pixel this is, starting at 0
    coord: the (x, y, z) position of the pixel as a tuple
    n_pixels: the total number of pixels

    Returns an (r, g, b) tuple in the range 0-255

    """
    # make moving stripes for x, y, and z
    x, y, z = coord

    r = color_utils.cos(z, offset=time * 0.1, period=5, minn=0, maxx=0.7)

    g = color_utils.cos(z, offset=time * 0.2, period=2.5, minn=0, maxx=0.7)

    b = color_utils.cos(x, offset=time * 0.1, period=10, minn=0, maxx=0.7)

    r, g, b = color_utils.contrast((r, g, b), 0.1, 2)


    # make a moving white dot showing the order of the pixels in the layout file
    spark_ii = (time*60) % n_pixels
    spark_rad = 10
    spark_val = max(0, (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad)
    spark_val = min(1, spark_val*64)
    #r += spark_val
    g += spark_val
    b += spark_val

    if ii % 10:
        if g > 0.3:
            b += spark_val
        else:
            g += spark_val

    else:
        if g < 0.3:
            b += spark_val
            r -= spark_val
        else:
            b = 0


    #print ii
    #
    
    if ii > 60 and ii < 120:
        r, g, b = 100

    # apply gamma curve
    # only do this on live leds, not in the simulator
    #r, g, b = color_utils.gamma((r, g, b), 2.2)

    return (r*256, g*256, b*256)
Esempio n. 5
0
    def moving_dot(self, t, coord, ii, n_pixels):
        # make a moving white dot showing the order of the pixels in the layout file
        spark_ii = (t*80) % n_pixels
        spark_rad = 8
        spark_val = max(0, (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad)
        if(spark_val==0):
            return None
        spark_val = min(1, spark_val*2)

        spark_val*=256
        return (spark_val, spark_val, spark_val)