Ejemplo n.º 1
0
        nx = random.randint(0, 15 - nw)
        ny = random.randint(0, 23 - nh)
        sub = n3[ny:ny+nh, nx:nx+nw]
        in_set = np.sum(sub == 0)
        partial = in_set / (nw * nh)
        print("%02d:%02d,%02d:%02d: %f" % (nx,nx+nw,ny,ny+nw,partial))
        tries += 1
        if 0.1 <= partial <= 0.6:
            print(nx, ny)
            print(sub)
            coords = [nx, ny, nx+nw, ny+nh]
            limits = [r1[ny], r1[ny+nh], r2[nx], r2[nx+nw]]
            return coords, limits


fluter = Fluter()

minx, maxx = -1.7, .7
miny, maxy = -1.0, 1.0
zoom = 1
maxiter = 100
while True:
    r1, r2, n3 = mandelbrot_set(minx, maxx, miny, maxy, 24, 16, maxiter)
    #r1, r2, n3 = mandelbrot_set(-1.7, .7, -1.0, 1.0, 24, 16, 100)
    #r1, r2, n3 = mandelbrot_set(-.8, -.7, 0, .2, 24, 16, 100)
    print(n3)
    #print(r1)
    #print(r2)

    a = draw(n3)
    fluter.send_array(a)
Ejemplo n.º 2
0
Implementation for Wireworld for our RGB-Wall

See https://en.wikipedia.org/wiki/Wireworld

TODO: multiple board layouts to chose from by program parm
TODO: set board layout by program parm

Created by kratenko
"""

import numpy as np
import time

from fluter import Fluter

fluter = Fluter()
W, H = 16, 24

EMPTY = 0
WIRE = 1
HEAD = 2
TAIL = 3

b_xor = """
..............x.
....x.....x...x.
...x.o...x.o..x.
...x.+...x.+..x.
...x.x...x.x..x.
...+.x...x.x..x.
...o.x...x.x..x.
Ejemplo n.º 3
0
import math
import os
from PIL import Image

from fluter import Fluter

W, H = 16, 24

f = np.random.randint(-1, 2, size=(H, W), dtype=np.int16)

FISH_BREED = 3
FISH_ENERGY = 5
SHARK_STARVE = 2
SHARK_BREED = 10

fluter = Fluter()
img_skull = Image.open(os.path.join("img", "skull.png"))
img_fish = Image.open(os.path.join("img", "cheep-cheep-blue.png"))


def send(f):
    water = [0, 0, 0]
    fish = [0, 0, 0xff]
    shark = [0, 0xff, 0]
    d = np.zeros((H, W, 3), dtype=np.uint8)
    d[f<0] = shark
    d[f==0] = water
    d[f>0] = fish
    fluter.send_array(d)

Ejemplo n.º 4
0
"""
RGB-Reel Conway's Game of Life

Simple implementation of Conway's Game of Life as reel for your wall. Runs in
a torus world and get's initialized randomly.

See https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

created by kratenko
"""
import numpy as np
import time
from fluter import Fluter

fluter = Fluter()

w = 16
h = 24

glider = [[1, 0, 0], [0, 1, 1], [1, 1, 0]]

f = np.random.randint(2, size=(h, w), dtype=np.uint8)
#f = np.zeros((h, w), dtype=np.uint8)
#f[:3, :3] = glider


def neigh(f, pos):
    x, y = pos
    xa = (x - 1) % w
    xb = x
    xc = (x + 1) % w
Ejemplo n.º 5
0
Uses our own WL-command to send complete picture in one go.

Created by kratenko.
"""
import os
import random
import time

from PIL import Image

from fluter import Fluter


def get_random_file(path):
    """
    Returns a random filename, chosen among the files of the given path.
    """
    files = os.listdir(path)
    index = random.randrange(0, len(files))
    return os.path.join(path, files[index])


fluter = Fluter()

while True:
    # prepare image (open, convert to rgba, resize, convert to array)
    fn = get_random_file("../images")
    print("sending image '{}'".format(fn))
    fluter.send_image(Image.open(fn))
    time.sleep(1)