diff --git a/patterns/curtain.py b/patterns/curtain.py new file mode 100644 index 0000000..7441b2d --- /dev/null +++ b/patterns/curtain.py @@ -0,0 +1,202 @@ +# Cloud +# Daniel Bailey +# Based on cubefill (Copyright (C) Alex Silcock ) +# 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,0,0,1], + [0,0,0,0,0,0,0,1], + [0,0,0,0,0,0,0,1] + ], + [ + [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,0,0,0,1], + [0,0,0,0,0,0,0,1], + [0,0,0,0,0,0,0,1] + ], + [ + [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,0,0,0,1,0], + [0,0,0,0,0,0,0,1], + [0,0,0,0,0,0,0,1] + ], + [ + [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,0,0,0,1,0,0], + [0,0,0,0,0,0,1,0], + [0,0,0,0,0,0,0,1] + ], + [ + [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], + [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] + ], + [ + [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], + [0,0,0,1,0,0,0,0], + [0,0,0,0,1,0,0,0], + [0,0,0,0,0,1,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], + [0,0,0,1,0,0,0,0], + [0,0,0,0,1,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], + [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