PK!144nummu/__init__.py__version__ = '0.1.9' from nummu.core import Nummu PK!q޼' nummu/core.pyimport warnings import 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 load(self, name, type, **meta): self.resources[name] = dict(type=type, **meta) def add(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'): warnings.warn('init is deprecated, use __init__ instead.', DeprecationWarning) 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'): # array2gif requires a transposed matrix compared to numpngw. seq = [] for s in self.seq: seq.append(np.transpose(s, axes=[1, 0, 2])) write_gif(seq, filename, fps=int(1000/delay)) else: raise NotImplementedError('Unsupported file format') PK! i ~Hjߧ;2<憷!Ǭn<1,+F7 _GrW9ȸ9_ =Q`>xAVDk/WIJVղMiuF*dLBn.&/'pv;oR C%g-%5V?~-] 6E+֘La76s73=D,fK:R0L }(bCצ]*MF?f|6pa JJa"gq XR3ᐘ'E @T&yPJm]# } {snpܴr$!2Sq3 0 q(~j5ϊt|5oNY67T8x{2D@ׁYI<fOsX%`r:PfR{[(h4v4Ow! ;v_`g8mǣY(mEx;ښvn]\kfG|;U/rA%zv`ZiM(,BUaF2F'T#Y/m2 i9Bk%jĔRĮ7`o&SMW]muuW$u݉t@>=zy-1T?tsKRWJ$kJ5/r2n/bSdEo0\c6티5?/+)Ucd^R_#V3>'yN[Kma0Ό:Bq:ivH 6 q}/&$ɖKݘ-7&Y"@Tf WgvRY $@ҕ@? 2W똴R)!zGp7V#ر=c rU OU^=|u7yJJDdz@X􇖕mET ~'SvsGruG_a?uL5˭ED1~k--|j6n\ rg^˿ o? f:S:e=ށZ3x/PK!HFM5m8nummu-0.1.9.dist-info/RECORDur@{ }ȡ#=hArغe',>TM)/WXU{du6]Wn=r&s 7|r?\*f0d* ȿ'49N $^6ҧjZ/GrC? ɀ d$]8=)Vem1˹Zp%׈ΥE '顤]tc\iչ 9͝? E[w`djҼ2mR'~LtnN,w o6~Q؇p%b8V^kf_6"rY8!S׬vtt 0^ț@>;:̥nPjkTuA DZgF`-;Z üPK!144nummu/__init__.pyPK!q޼' cnummu/core.pyPK!