Exemplo n.º 1
0
def send(screen):
    global prev_screen
    w = screen.get_width()
    h = screen.get_height()
    pxarray = pygame.PixelArray(screen)
    if prev_screen:
        prev_pxarray = pygame.PixelArray(prev_screen)
        xs = set()
        ys = set()
        for y in range(h):
            for x in range(w):
                if not pxarray[x][y] == prev_pxarray[x][y]:
                    xs.add(x)
                    ys.add(y)
    else:
        xs = set((0, client.WIDTH-1))
        ys = set((0, client.HEIGHT-1))

    if not xs:
        return
    prev_screen = screen.copy()

    pixels = []
    for y in range(min(ys), max(ys)+1):
        for x in range(min(xs), max(xs)+1):
            pixels.append(pxarray[x][y])
    del pxarray
    client.blit(min(xs), min(ys), max(xs)-min(xs)+1, max(ys)-min(ys)+1, pixels)
Exemplo n.º 2
0
def test():
    clearscreen.clear()
    client.write(0, 0, "Hello World!")
    x = 0
    y = 1
    for c in sorted(FONT.keys()):
        client.blit(x * client.PWIDTH, y * client.PHEIGHT, client.PWIDTH,
                    client.PHEIGHT, client.char_to_pixel_segment(c))
        x += 1
        if (x > 15):
            x = 0
            y += 1
Exemplo n.º 3
0
#!/usr/bin/env python2
import client
import random
import time
import clearscreen

if __name__ == "__main__":
    t = 0
    s = 64
    pixels = [0] * client.HEIGHT * client.WIDTH
    clearscreen.clear()
    while True:
        if t == 63:
            time.sleep(1)
        t = (t + 1) % 64
        for x in range(client.WIDTH):
            for y in range(client.HEIGHT):
                #pixels[s * x + y] = 0 if (y == (x^t)) else 1
                pixels[s * x + y] = 0 if ((x & y & t)) else 255
        client.blit(0, 0, client.WIDTH, client.HEIGHT, pixels)
        print t
        #time.sleep(0.09)
Exemplo n.º 4
0
def bright(b, x, y, w, h):
    pixels = [b] * w * h
    client.blit(x,y,w,h,pixels)
Exemplo n.º 5
0
#!/usr/bin/env python2
import client
import random
import time

blockx = 5
blocky = 7

if __name__ == "__main__":
    while (True):
        x = random.random() * (client.WIDTH / blockx)
        y = random.random() * (client.HEIGHT / blocky)
        x = int(x) * blockx
        y = int(y) * blocky
        if random.random() > 0.5:
            bright = random.random()
            bright = (bright * bright) * 255
            pix = [int(bright)] * blockx * blocky
            client.blit(x, y, blockx, blocky, pix)
        else:
            pix = [0] * blockx * blocky
            client.blit(x, y, blockx, blocky, pix)
Exemplo n.º 6
0
# Move everything up one pixel and generate new fire at the bottom
def move_and_smooth(current, new):
    global cool_offs
    for x in range(1, client.WIDTH - 2):
        for y in range(1, client.HEIGHT - 2):
            new[y * client.WIDTH + x] = avg_cooled(x, y + 1, current)
    for i in range(5, client.WIDTH - 5, 3):
        bright = int(random.random() * 180 + 70)
        new[(client.HEIGHT - 1) * client.WIDTH + i] = bright
        new[(client.HEIGHT - 1) * client.WIDTH + i + 1] = bright
        new[(client.HEIGHT - 1) * client.WIDTH + i + 2] = bright
        new[(client.HEIGHT - 2) * client.WIDTH + i] = bright
        new[(client.HEIGHT - 2) * client.WIDTH + i + 1] = bright
        new[(client.HEIGHT - 2) * client.WIDTH + i + 2] = bright
    # The cool map moves as well
    cool_offs = (cool_offs - 1) % client.HEIGHT


if __name__ == "__main__":
    current = init_fire()
    new = [0] * client.HEIGHT * client.WIDTH
    sending = [(x * x) / 256 for x in current]
    while (True):
        client.blit(0, 0, client.WIDTH, client.HEIGHT, sending, rec=False)
        move_and_smooth(current, new)
        current = new
        # x^2 will work better with the brightness levels we have
        sending = [(x * x) / 256 for x in current]
        client.rec()
Exemplo n.º 7
0
def clear():
    pixels = [0] * client.HEIGHT * client.WIDTH
    client.blit(0, 0, client.WIDTH, client.HEIGHT, pixels)