fills the screen with Link sprites using different zoom levels
#image converted on TI-Planet #tiplanet.org/img2calc from kandinsky import fill_rect #the image drawing function #- rle : image RLE-compressed data #- w : width of image #- pal : palette of colors to use with image #- zoomx : horizontal zoom #- zoomy : vertical zoom #- itransp : index of 1 transparent color in palette or -1 if none 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 for your image #18 RGB-888 colors palette = ( "#000000","#202020","#509000","#78b418","#f87800","#f0a068","#e860b0","#b86818","w","#303430","#40d870","#309068","#885820","#2020c8","#e09050","#8080f0","#f0d840","#c01018", ) #your image data #16x22 RLE-5 pixels image = ( b"\xa0\1\xe1\0\xc0\2\1\"\3\2!\xe0\1\1\"\xe3\0\2\1\xe0\0\1\0!\4\"\3\2\4\1\2!\0\1\5\1\6!\xe4\0!\2\1\5!\5\1F\xe1\0&!\5!\a\5\1\xe6\1\1\5\a!\a\1\6\xe1\1\6\1\a\1\0\1\a\1\a('(\a\1\a\1@\1'\b\1%\1\b'\1\xe0\0!\a\5\1%\1\5\a!@\t\n\v\1\a\tE\a\1\v\n\1\0\t\b\xe9\0\b\t\a!+\1\f\1\t\xa8\1\t\1\v\n\v\1,\1\t\b\xed\0\b\tJ\v!\16\1\t\b\r/\r\b\t\nK\1.\1\t\b\r/\r\b\t\20\x010\v\1\16\1\t\b\r/\r\b\t0+A \t\b-\b\tK!\21\1\xe0\0\t(\t\xe1\0\21\4!\x80\1)\xe1\1\xe0\1\xa1\1\x80\1" ) l = ( (0,0,4,4), (64,0,3,3), (64,66,3,1), (112,0,2,3), (112,66,2,1), (144,0,1,3), (144,66,1,1), ) for v in l: for ky in (-1, 1): for kx in (-1, 1): draw_image(image, 160 + v[0]*kx, 96 + v[1]*ky, 16, palette, zoomx=v[2]*kx, zoomy=v[3]*ky, itransp=0)