PK!$E(O44nummu/__init__.py__version__ = '0.1.5' from nummu.core import Nummu PK!GlVV 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'): # 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!@44 nummu/draw.pyimport numpy as np from PIL import Image, ImageDraw, ImageFont def _get_rect(x, y, width, height, angle): rect = np.array([(0, 0), (width, 0), (width, height), (0, height), (0, 0)]) theta = (np.pi / 180.0) * angle R = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]) return np.dot(rect, R) + np.array([x, y]) def rect(pallete, x, y, w, h, angle=0, color=0): _rect = _get_rect(x, y, w, h, angle) img = Image.fromarray(pallete) draw = ImageDraw.Draw(img) draw.polygon([tuple(p) for p in _rect], fill=color) pallete[:, :, :] = np.asarray(img) def line(pallete, x1, y1, x2, y2, color=0): img = Image.fromarray(pallete) draw = ImageDraw.Draw(img) draw.line((x1, y1, x2, y2), fill=color) pallete[:, :, :] = np.asarray(img) def image(pallete, x, y, img): bg = Image.fromarray(pallete) if isinstance(img, str): _img = Image.open(img) bg.paste(_img, (x, y), _img) else: raise ValueError('unknown img type.') pallete[:, :, :] = np.asarray(bg) PK!3:&&nummu/errors.pyclass NummuError(Exception): pass PK!BR''nummu-0.1.5.dist-info/LICENSEMIT License Copyright (c) 2018 Soasme Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HNɡSTnummu-0.1.5.dist-info/WHEEL HM K-*ϳR03rOK-J,/R(O-)T03"]b݀ҢԜ$+TtJcݼTļJ.PK!H Mnk'nummu-0.1.5.dist-info/METADATAWOS7CfbO?lӝ8:mBh!́ay٫JZs?\_?IkcI\XOO-pۿB뇽*Xmt^8 N@jWȹߜX/I̩]G?p1UeR"Cވ^)"\ܮX[%|@r2G;a7˸b&Ҏ+碘7WT;f ?}} 6Ek֘La76s?3 B:bůq] Xyܝa٣;N=¡mCeMumCYMʦt T*s_/ f=uxL ;tg0qΓAJF4c?Ml'|HN7)v~aݚb^2y^>ZuPK}d=%icNj.]:.Ա pz\?:.MO ɒ0\<\S|. ucJt8y$( meApqq.YJ6X쩰Z8NXwSr} b*ИZʸ3ą8e3%;yɄm0y MD;sàgNE,;1w!N{)"ٲS2T42DB`Tb^3-W]2Yʐ$P+Ə{ruJhxtW–#ȱ7/U/Z@:Id]۫{`9ѩuț\ FlETgsv{65_ ?yD#c5J^^.E͕Pp?9mZ{e\tjRg$Pضu7 I=ZY ˬE"np 5RbaYx14mUOȽP=TgW̹9AGъA))`J_6յ꫿(J00n}7 -S?/^mPK!$E(O44nummu/__init__.pyPK!GlVV cnummu/core.pyPK!@44 nummu/draw.pyPK!3:&&C nummu/errors.pyPK!BR'' nummu-0.1.5.dist-info/LICENSEPK!HNɡSTnummu-0.1.5.dist-info/WHEELPK!H Mnk'nummu-0.1.5.dist-info/METADATAPK!Hc$߀8Vnummu-0.1.5.dist-info/RECORDPK