2

Pico-8 implementation of Scale2x and Scale3x. Original algorithms by Andrea Mazzoleni

Scale2x:

 ```--[[ sind : sprite index sz_x : x size sz_y : y size sx : screen pos x sy : screen pos y alpha: color to make transparent ]]-- function scale2x(sind,sz_x,sz_y,sx,sy,alpha) alpha=alpha or 0 local offx=sind%16 local offy=flr(sind/16) local soffx=offx*8 local soffy=offy*8 local sizex=sz_x-1 local sizey=sz_y-1 local a,b,c,d,e,f,g,h,i, e0,e1,e2,e3,x0,y0 for y=0,sizey do for x=0,sizex do e=sget(soffx+x,soffy+y) a=e b=e c=e d=e f=e g=e h=e i=e if y>0 then b=sget(soffx+x,soffy+y-1) end if y0 then d=sget(soffx+x-1,soffy+y) if y>0 then a=sget(soffx+x-1,soffy+y-1) end if y0 then c=sget(soffx+x+1,soffy+y-1) end if y

Scale3x:

 ```--[[ sind : sprite index sz_x : x size sz_y : y size sx : screen pos x sy : screen pos y alpha: color to make transparent ]]-- function scale3x(sind,sz_x,sz_y,sx,sy,alpha) alpha=alpha or 0 local offx=sind%16 local offy=flr(sind/16) local soffx=offx*8 local soffy=offy*8 local sizex=sz_x-1 local sizey=sz_y-1 local a,b,c,d,e,f,g,h,i, e0,e1,e2,e3,e4,e5,e6,e7,e8, x0,y0 for y=0,sizey do for x=0,sizex do e=sget(soffx+x,soffy+y) a=e b=e c=e d=e f=e h=e i=e g=e if y>0 then b=sget(soffx+x,soffy+y-1) end if y0 then d=sget(soffx+x-1,soffy+y) if y>0 then a=sget(soffx+x-1,soffy+y-1) end if y0 then c=sget(soffx+x+1,soffy+y-1) end if y
P#23217 2016-06-19 13:56 ( Edited 2016-06-19 18:00)