from kandinsky import fill_rect from time import sleep def draw_image(rle, x0, y0, w, pal, zoomx=1, zoomy=1, itransp=-1): i, x = 0, 0 x0, y0 = int(x0), int(y0) nvals = len(pal) nbits = 0 nvals -= 1 while(nvals): nvals >>= 1 nbits += 1 maskval = (1 << nbits) - 1 maskcnt = (0xFF >> nbits >> 1) << nbits while i<len(rle): v = rle[i] mv = v & maskval c = (v & maskcnt) >> nbits if (v & 0b10000000 or nbits == 8): i += 1 c |= rle[i] << (7 - nbits + (nbits == 8)) c = c + 1 while c: cw = min(c, w - x) if mv != itransp: fill_rect(x0 + x*zoomx, y0, cw*zoomx, zoomy, pal[mv]) c -= cw x = (x + cw) % w y0 += x == 0 and zoomy i += 1 palette = ( "#000000","#a0d8b0","#c0e4c8","#f8fcf8","#f0e8d8","#d0dcc8","#e0ecd8","#709080", ) image0 = ( b"\xd3\3\4#\4\23\4\xe3\1\4s\4\xbb\1\x043\5\3\t\5\t\2\33\4\x9b\1\4C\31\6)\6\x9b\1\4Ci\x8b\1\4Cq\23\4c\fC\xf9\0\23\4S\4S\4\21\2\t\5\x041\x93\1\31\33I\4)\xfb\0\1\2\31\4\23A\2\t\2\31\4\23\x043\4\v\21\4\t\4\1\6\vQ\2\1\4\21[\5\3!\f\21\v\1\2\t\2\1\x041\4\t#\4#\4\3\2!\4!\vq[\4\3Y\vaC\4+\t\2\t\x041\3\n\24\31\2\1\3\21\2\tSa\3\4\v\5\v\4\t\3A3\4\v\21\2\21\2!\4\6\31\4\3\4Y+\4\v\f\2\1\24\1\2\21\4\3!\5\1\3\4\31\2)+\4\v\31\5\31\4\t\4\31\2\4\21\x041\4\31\v\4\v\5\vQ\4\6\2\5\f\5\4\21\x051\4\31\v\4\23\5\3\31\x021\4\2\24\5\4\21\4\2\t\2\21\4\31\3\f\v\4\v\31\5\31\2\t\4\31\f\21\5\1\5!\6\21\4#\4\23\21\4\1\2!\4\3\21\5\4\t\3\4!\2\5\2\31#\4\23)\2\31\3\4\3\21\4\1\3\4aK1\23\t\f\23\f\3\t\2\31\2!c\4#!\24\t\vI\2\1\3\4\33\4KY\v\t\2\t\4\2!sq\vIs\1\x041\4)\23\t\2!\2\3\4+\4#\2\4\1\4a\6\v\1\2\21\2\1s\4\31\4a\23\4\2\21\5\v\4k\31\2\4\1\2\1\x021\4\23\5\xfb\0\4\33\2)\4\5\t\2\1\2\4\2\1#\4\xfb\0\4\23\x81\1\xb3\1\4\23A\2!\xc3\1\4\3\5\3\1\2Y3\4\x93\1\5\v)\5\1\2\x113\4\xa3\1\4\33\2\1\2\6\1\27\xfb\1\4#'\33\4\xeb\1\4\v\a\4\27\3\f\x93\2'\xab\2'\xa3\2\5'\xa3\x027\x93\2G\x83\2W\xf3\1'\25'\xe3\1w\xdb\1/\4\r/\xd3\1\xff\0\5\xcb\1\x87\1\xcb\1g\5\17\xe3\1_\x9b\2\4\xab\1" ) image1 = ( b"\xf8\b\21\2\0;\xd8\19\v\x043\xb8\1QC\xa0\1\3YC\x98\1\3a\6#\2\1\6\3\x90\1\31\2\21(\3\4\v\1 \6\x80\x011\x051\23\1(\th\v \4A\v\18\2\5X\v\1(A\4\3@\21P\v\x0101\3\4@!@\23\x010\t\2\t\2\1\v8)\x030#8)\3A\5)\3(#\x010\21\309 \21\3(+A0\318\21(#\4\3\2!H\1P\t(\3\f\23\f\3\2`\4P\1\6(\23\21\2\23\4\3\1\xa8\1\1\3(\v8\2\3\4\xb0\1\3(\3\1\xa8\1\2\1@\3\x80\2\1\3\1 \1\4\3(\3\1\xa0\1\4 \24\2\1\23(\tH\t\xf8\0\1+(\21(!8\18\1#()\5!8\318#(\3\xf9\0\x0310\1\x1b0)\49\v18\23@!@\v90\vH\3\318\2\v\t\2) \1\3X\3\1\4\18\vI\4\20\1p\3\t0\23\1(\4\21\4\t\2\x80\x011\3\f\x030!\5\1\x90\1\3\31#a\x98\1\5CY\xa8\1K!\2\31\xb8\1K\6)\6\xd0\1#\4\27\b\23\xf0+" ) image2 = ( b"\xf8\b\33\0\v\2\1\2\v\xe0\1#!\4)\xc0\1#i\xa8\1+\xf9\0\x98\x013\xf9\0\3\x90\x0130\1\4\x021\3\x80\1\3\21\23\4Q(\vh\3\1 \4\vI0\v\4X\2\t(\v1\5\18\33P\21(\1\v)\4@#@\x190\v\21\2Q30\3\x190\1\3!\x021\v\x043(\3!0\v\1\30![(\2a\x030\t#\1\4\1#(!\x041H\v\18\23(\1\f\22\f\t`\4P\v(I\4\t\xa8\1\2\3(\2\18\t\5\xb0\1\3(\3\1\xa8\1\t@\1\x80\2\21 \1\4\3(\3\xa8\1\4 \24\2\21\3(\vH\6\3\xf8\0)\3(\x130\33\x80\1!\3(#\2\5#\2\20\5\b\4\t\3@\31\3(Sa8\31\x030+\4\x031\2)\3@\t\3@+8\598\tH#8A\x030\21P\v\4\38\31\2\31\3\1(\t`\x130\21\2(\4\3 \1\x80\1\x031\4\5\x010\1\33\4\3\x90\1\3\xf9\0+\xa0\1\xf9\0#\xb0\1i#\xc0\1\1\2I#\xd8\1\3\21\4\2\1\a\b\23\xf0+" ) image3 = ( b"\xf8\b\21\2\b\v\4\23\xe0\19C\xb8\1\3QC\xa0\1\3YC\x98\1\3\31\29#\31\3\x90\x0110\3\4\v1\x80\x011\x051\x130\t\3`\v \4A\v8\t\4\3P\v09\2\3@\4\21\3@\x1309\v@!8\338\t\2\t\2\1\3@1\3(\33\x0101\3\xf9\0\3(#8\21\5\f\0\6A\4)(+A0q(#\4\vp\218\21(\3\f\23\f\3\2`\4P\1\3(K\4\vP\1P\3(\v\2(\1\v\4P\1P\3(\v\xa8\1\v\28\v(\3\1\xa8\1\3\4\33\1\20\3\4\3(\3\1\xa0\1\4\21\33\4#(\3\1H\t@);(\3\t()(\493(\3!\2A\0\5\4\2\218+(\3I(\3)8#(\3)\4\18\2)8#8\21\2\t@90\6\vP\31@\3\2\t\2\x190\23X\5\2\1@I(\3\5h\t8\3@\t\30\6\x80\19\3\48!\2\1\x98\1!\238)\xa0\1;8!\xb0\x013\6Q\xc0\1;9\3\xe8\1\v\0\37\21\3\xf0+" ) fill_rect(0,0,320,222,(255,255,255)) while True: for i in range(4): draw_image(eval('image'+str(i)), 70, 0, 43, palette, zoomx=4, zoomy=4, itransp=0) sleep(.05)