PK!44nummu/__init__.py__version__ = '0.1.2' from nummu.core import Nummu PK! nummu/core.pyimport numpy as np 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() write_apng(filename, self.seq, delay=delay, use_palette=True) 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.2.dist-info/WHEEL A н#J@Z|Jmqvh&#hڭw fi4WZ^EgM_-]0(q7PK!H H%F8nummu-0.1.2.dist-info/METADATATMo6Wk]کS@&vuFԇ ii$K*IEVνs\ѿRv r8oE)XIs8h1ݷm|XgaŽ9< lFhm0-.;2zj>?}cl?p&t\b+ZSV6Eɏ|w O:[/[dD d%_XS[ѶRp&t3!{/t>0zHNVvx]QAoޖfI2?ϓiO6?PF: R (;:{((H֍!7oU-i^} HV= ooMN)O,