PK!y44nummu/__init__.py__version__ = '0.1.4' 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!$22 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) PK!3:&&nummu/errors.pyclass NummuError(Exception): pass PK!BR''nummu-0.1.4.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.4.dist-info/WHEEL HM K-*ϳR03rOK-J,/R(O-)T03"]b݀ҢԜ$+TtJcݼTļJ.PK!H%# nummu-0.1.4.dist-info/METADATAVn6)p좻+d&vu6F4 rZUFsktHH.^g8+,bC(#or COK2YVi%9F{"~I,Y~yr~QT~Ͳ9YJ0㏉YȽ_KTb{ϧ;ΘR~D.,놜w*t9cQh,t.)?u$6οߟt=w-__DRw 5ޞ]ADJZYHF. o3HغZI(d R7qqx4 <8 p1'R4 u4;itO x΢i8ZKK<_#07' v hj%M>wv+嘣LJ+Eu,~^[RaDwv.oE#e eodfYyJ^RQ|zC`ʼ4=E +4hAr*TC!eNQQGy ` ;UVUIv"4)YZcwR"6.rj|5JdƬ^Ds(5E9pbE(`+7>YTͯ!E-cBq ۞C<hʡNUƬ5ƂdN bпgy tR yqZ{pg'A{E-\jQQCp< 9\Cqj<:Zh8l|h& '>腓(w5圙xjJ\:pr#9Yl6B鬬Vc{IS!4^gyi7))m\&.A1eN0VD$ jYe(7x )I8m0lO#=.-6s@x$PK!y44nummu/__init__.pyPK! 9$ cnummu/core.pyPK!$22 /nummu/draw.pyPK!3:&& nummu/errors.pyPK!BR'' nummu-0.1.4.dist-info/LICENSEPK!HNɡSTAnummu-0.1.4.dist-info/WHEELPK!H%# nummu-0.1.4.dist-info/METADATAPK!Hl9m{7nummu-0.1.4.dist-info/RECORDPK