def draw_image(x, y, image_data, w=5, h=5):
    dw = picounicorn.get_width()
    dh = picounicorn.get_height()
    for xi in range(5):
        if xi + x >= dw:
            return
        if xi + x < 0:
            continue
        for yi in range(5):
            if yi + y >= dh:
                break
            print(xi + x, yi + y)
            pixel = image_data[yi * h + xi]
            # We've inverted X Y here.
            picounicorn.set_pixel(x + xi, y + yi, pixel[0], pixel[1], pixel[2])
Example #2
0
    i = i % 6
    if i == 0:
        return v, t, p
    if i == 1:
        return q, v, p
    if i == 2:
        return p, v, t
    if i == 3:
        return p, q, v
    if i == 4:
        return t, p, v
    if i == 5:
        return v, p, q


width = picounicorn.get_width()
height = picounicorn.get_height()

print("Running!")

while not picounicorn.is_pressed(
        picounicorn.BUTTON_A):  # Wait for Button A to be pressed
    # Scroll red across
    for x in range(width):
        for y in range(height):
            r, g, b = [int(c * 255) for c in hsv_to_rgb(x / width, 1.0, 1.0)]
            picounicorn.set_pixel(x, y, r, g, b)
        time.sleep_ms(50)

    # Clear the display
    for x in range(width):
Example #3
0
def get_screen():
    # get the screen width/height
    return picounicorn.get_width(), picounicorn.get_height()
Example #4
0
    if i == 0:
        return v, t, p
    if i == 1:
        return q, v, p
    if i == 2:
        return p, v, t
    if i == 3:
        return p, q, v
    if i == 4:
        return t, p, v
    if i == 5:
        return v, p, q


#Define setup variables
w = picounicorn.get_width()  #16
h = picounicorn.get_height()  #7
startballx = 7
startbally = 3
startdirH = 1
startdirV = 0
startscoreXY = 0
startscoreAB = 0
onlistAB = [2, 3, 4]
onlistXY = [2, 3, 4]

#Create lists of pixels for the height/width of the whole display/ball area
listW = []  #makes a list 0-15
for i in range(w):
    listW.append(i)
def set_all(r, g, b):
    w = picounicorn.get_width()
    h = picounicorn.get_height()
    for x in range(w):
        for y in range(h):
            picounicorn.set_pixel(x, y, r, g, b)