Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions patterns/curtain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
# Cloud
# Daniel Bailey
# Based on cubefill (Copyright (C) Alex Silcock <alex@alexsilcock.net>)
# Released under the terms of the GNU General Public License version 3

import cubehelper
import math
import random

def frame_reverse(frame):
if frame > 14:
return 14 - frame
return frame

class Pattern(object):
def init(self):
self.double_buffer = True
self.restart()
return 0.6 / self.cube.size

def restart(self):
self.lineanim = [
[
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1]
],
[
[0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1]
],
[
[0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1]
],
[
[0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1]
],
[
[0,0,0,1,0,0,0,0],
[0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,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
[0,1,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0],
[0,0,0,1,0,0,0,0]
],
[
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0]
],
[
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0]
],
[
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0]
],
]
self.filling_color = 0
self.red = (2.0,0.0,0.0)
self.green = (0.0,2.0,0.0)
self.blue = (0.0,0.0,2.0)
self.off = (0.0,0.0,0.0)
self.frame = 0
self.framelimit = (14)
self.lastframe = (self.framelimit + 14)
self.colourmatrix = [[None]*self.cube.size]*self.cube.size
for y in range(self.cube.size):
for x in range(self.cube.size):
self.colourmatrix[x][y] = cubehelper.random_color()


def tick(self):

for y in range(self.cube.size):
for x in range(self.cube.size):
for z in range(self.cube.size):
if self.lineanim[(frame_reverse((self.frame + z) % self.lastframe)) ][y][x]:
self.cube.set_pixel((x, y, z), self.colourmatrix[x][z])
else:
self.cube.set_pixel((x, y, z), self.off)

if self.frame >= self.lastframe:
self.restart()
raise StopIteration
else:
self.frame += 1