Ejemplo n.º 1
0
    def generate(self, step, dumpworld):
        # generate empty world
        world = np.zeros([3, self.dim[0], self.dim[1]])

        # generate current position
        temp_d = self.distance
        temp_theta = sawtooth(self.theta * step) * np.pi

        [sx, sy] = polar2z(temp_d, temp_theta)

        x = 9.5 - np.sin(step * self.moving) * self.amplitude

        # switch on leds depending on distance
        world[0, :, :] = sphere2d(x + sx, sy + self.dim[1] / 2 - 0.5,
                                  self.fade)
        world[1, :, :] = world[0, :, :]
        world[2, :, :] = world[0, :, :]

        if not self.test:
            # convert it to 2d
            world3d = convert2d(world)
        else:
            world3d = world

        return world3d
Ejemplo n.º 2
0
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, self.dim[0], self.dim[1]])
        self.lastworld = np.roll(self.lastworld, axis=2, shift=-self.dir)

        # proces old world
        if self.dir == -1:
            self.lastworld[:, :, 0] = 0.0
        else:
            # up to down
            self.lastworld[:, :, -1] = 0.0

        # proces old world
        if step % self.wait == 0:
            for i in range(self.number):
                if self.dir == -1:
                    pass
                    #                    self.lastworld[ :, 9, :] = 0.0
                    #                    self.lastworld[:, 10:, :] = 0.0
                    world_2d[:, randint(0, self.dim[0] - 1), 0] = 1.0
                else:
                    # up to down
                    world_2d[:, randint(0, self.dim[0] - 1), -1] = 1.0

        world_2d[:, :, :] += self.lastworld
        self.lastworld[:, :, :] = world_2d[:, :, :]

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, self.dim[0], self.dim[1]])

        # move to the sides
        left = np.roll(self.lastworld, axis=1, shift=-1)
        right = np.roll(self.lastworld, axis=1, shift=1)

        # delete everything half part
        left[:, int(self.dim[0] / 2) - 1:, :] = 0.0
        right[:, :int(self.dim[0] / 2) + 1, :] = 0.0

        # turn on new leds
        for i in range(self.number):
            # left
            world_2d[:,
                     int(self.dim[0] / 2) - 1,
                     randint(0, self.dim[1] - 1)] = 1.0
            # right
            world_2d[:, int(self.dim[0] / 2),
                     randint(0, self.dim[1] - 1)] = 1.0

        # patch together worlds
        world_2d[:, :, :] += right[:, :, :]
        world_2d[:, :, :] += left[:, :, :]
        self.lastworld[:, :, :] = world_2d[:, :, :]

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)
Ejemplo n.º 4
0
    def generate(self, step, dumpworld):

        # create world
        world_2d = np.zeros([3, self.dim[0], self.dim[1]])

        # make square bigger
        if self.step < min(self.dim) / 2:
            fac = int(max(self.dim) / min(self.dim))
            # print square
            world_2d[:, self.step * fac:self.dim[0] - self.step * fac,
                     self.step:self.dim[1] - self.step] = 1.0

            # make inner white
            world_2d[:, self.step * fac + 1:self.dim[0] - self.step * fac - 1,
                     self.step + 1:self.dim[1] - self.step - 1] = 0.0

            self.step += 1
        # waiting frames
        elif self.step > self.wait + min(self.dim) / 2:
            self.step = 0
        # reset
        else:
            self.step += 1

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, self.dim[0], self.dim[1]])

        for i in range(self.number):
            world_2d[:,
                     randint(0, self.dim[0] - 1),
                     randint(0, self.dim[1] - 1)] = 1

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)
Ejemplo n.º 6
0
    def generate(self, step, dumpworld):
        # generate empty world
        world = np.zeros([3, self.dim[0], self.dim[1]])

        for i in range(10):
            world[:, i, :] = round(i / 10.0, 2)
            world[:, -(i + 1), :] = round(i / 10.0, 2)

        world = world**self.amplitude
        world -= uniform(0, 1)

        if not self.test:
            # convert it to 2d
            world3d = convert2d(world)
        else:
            world3d = world

        return world3d
Ejemplo n.º 7
0
    def generate(self, step, dumpworld):

        world2d = np.zeros([3, self.dim[0], self.dim[1]])

        # calculate current radius
        size = (sawtooth(step * self.speed) +
                1) * 0.5 * (self.maxsize - self.minsize) + self.minsize

        # creates hollow sphere with parameters
        world2d[0, :, :] = circle2d(size, self.dim[0] / 2 - 0.5,
                                    self.dim[1] / 2 - 0.5)
        world2d[1:, :, :] = world2d[0, :, :]
        world2d[2:, :, :] = world2d[0, :, :]

        if not self.test:
            # convert it to 2d
            world = convert2d(world2d)
        else:
            world = world2d

        return np.clip(world, 0, 1)
Ejemplo n.º 8
0
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, self.dim[0], self.dim[1]])

        for i in range(self.number):
            x = randint(0, self.dim[0] - 1)
            y = randint(0, self.dim[1] - 1)

            size = randint(0, 5)

            world_2d[:, x - size:x + size, y - size:y + size] = 1.0
            world_2d[:, x - size + 1:x + size - 1,
                     y - size + 1:y + size - 1] = 0.0

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)
Ejemplo n.º 9
0
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, 20, 10])

        if self.counter >= 20:
            self.counter = 0
        else:
            world_2d[0, self.counter, :] = 1.0
            self.counter += 1

        world_2d[:, 0, :] = 1.0
        world_2d[:, -1, :] = 1.0
        world_2d[:, :, 0] = 1.0
        world_2d[:, :, -1] = 1.0

        #        world_2d[0, :, 0] = 1.0
        #        world_2d[1, :, 10] = 1.0
        #        world_2d[2, :, 20] = 1.0
        #        world_2d[0, :, 30] = 1.0

        world = convert2d(world_2d)

        return np.clip(world, 0, 1)
    def generate(self, step, dumpworld):

        world_2d = np.zeros([3, self.dim[0], self.dim[1]])

        if self.counter == 0:
            self.counter = len(self.patch_frames)
            self.pos = [randint(0,54), randint(0,4)]

        else:
            world_2d[0, self.pos[0]:self.pos[0]+6, self.pos[1]:self.pos[1]+5] = self.patch_frames[-self.counter]

            world_2d[1, :, :] = world_2d[0, :, :]
            world_2d[2, :, :] = world_2d[0, :, :]

            self.counter -= 1

        if not self.test:
            # convert it to 2d
            world = convert2d(world_2d)
        else:
            world = world_2d

        return np.clip(world, 0, 1)