PK!'44nummu/__init__.py__version__ = '0.1.3' from nummu.core import Nummu PK! 9$ nummu/core.pyimport numpy as np from array2gif import write_gif from numpngw import write_apng class Nummu: def __init__(self, height, weight): self.seq = [] self.is_quit = False self.modules = [] self.resources = {} self.height = height self.weight = weight def add(self, name, type, **meta): self.resources[name] = dict(type=type, **meta) def extend(self, mod): self.modules.append(mod) def quit(self): self.is_quit = True def _run_init(self): for mod in self.modules: if hasattr(mod, 'init'): mod.init() def _run_update(self, delta): for mod in self.modules: if hasattr(mod, 'update'): mod.update(delta) def _run_draw(self): palette = np.zeros((self.height, self.weight, 3), dtype=np.uint8) for mod in self.modules: if hasattr(mod, 'draw'): mod.draw(palette) self.seq.append(palette) def export(self, filename, delay, length=30000): self._run_init() progress = 0 while not self.is_quit: try: self._run_update(delay) self._run_draw() progress += delay if progress >= length: raise StopIteration except StopIteration: self.quit() if filename.endswith('.png'): write_apng(filename, self.seq, delay=delay, use_palette=True) elif filename.endswith('.gif'): write_gif(self.seq, filename, fps=int(1000/delay)) else: raise NotImplementedError('Unsupported file format') PK!߽44 nummu/draw.pyWHITE = (255, 255, 255) def line(pallete, color, x1, y1, x2, y2, *args): if len(args) % 2 != 0: raise TypeError('invalid additional points.') points = [(x1, y1), (x2, y2), ] + list(args) for (a1, b1), (a2, b2) in zip(points[:-1], points[1:]): print(a1, b1, a2, b2, color) if isinstance(color, int): pallete[a1:a2, b1:b2, :] = color else: for r, g, b in color: pallete[a1:a2, b1:b2, 0] = r pallete[a1:a2, b1:b2, 1] = g pallete[a1:a2, b1:b2, 2] = b PK!3:&&nummu/errors.pyclass NummuError(Exception): pass PK!HǎASSnummu-0.1.3.dist-info/WHEEL A н#J@Z|Jmqvh&#hڭw fi4WZ^EgM_-]0(q7PK!H/<fnummu-0.1.3.dist-info/METADATATMoFW)TdN" ֕ƩA!r]fνs\ѿ.v H7g"^,E)&VԘn뺍>~X'Q)< Dm45.2fj ~~lLu*gߒ/{+-EO~ɳ %Ou^S$D d!_XSZQRp&tr)ه k'_}?,eA{0?&]v)'F{~y7[ur(Aϟ(%E(A%4do{(H9(x"ϮB c,( یۥ:qT8^@mˍ.7혼ڃ7eNxC%sQ'H.k nb09*/CnE7B8N`k4)8EM;nQGՃ *JD̕*O :T~nѮ &k?Ąay$`o!?T$2tϢSƥU)IpnXWAWC'+Z!ɛV249<0mÝ(BYlbд4X,(:pV-c uBz }]\ĐbT#0;rR*Ӫ4RPK!HJeHPnummu-0.1.3.dist-info/RECORDuI0o h@@w* (`S5U^4miq$c\Ն j]ggřstE $GCҏEcom+[J'AhȖ'; keMy- ǂs#{\]w#سW`ۜ7ޭC W2V3fZmNזmӍ@eT=!V]{Z@TnC^䓼q9ͪ~0{'{91l@㤀R$WlA9i-w]*P/B#vD9yYȧv]YD+*Hf\fUm3PK!'44nummu/__init__.pyPK! 9$ cnummu/core.pyPK!߽44 /nummu/draw.pyPK!3:&& nummu/errors.pyPK!HǎASS nummu-0.1.3.dist-info/WHEELPK!H/<fm nummu-0.1.3.dist-info/METADATAPK!HJeHPPnummu-0.1.3.dist-info/RECORDPK