-- Replace side direction drawings only. Keep front/back contact repairs. local src=app.open('art/sprites/fiddler_walk_contacts_v1.png') local atlas=Image(src.cels[1].image);src:close() for row,name in ipairs({'west','east'}) do local path=app.params[name] local source=app.open(path) local keys=Image(source.cels[1].image);source:close() for col=0,3 do local frame=Image(48,64,ColorMode.RGB) frame:drawImage(keys,Point(-col*48,0)) -- Depth shading identifies the near/far legs when their contact silhouettes -- overlap. The opposite half-cycle swaps which leg crosses in front. if name=='east' and col>=2 then for y=46,61 do for x=12,39 do local c=frame:getPixel(x,y) local r,g,b,a=app.pixelColor.rgbaR(c),app.pixelColor.rgbaG(c),app.pixelColor.rgbaB(c),app.pixelColor.rgbaA(c) if a>0 and r>g and g>=b then local far=(col==2 and x>=24) or (col==3 and x<=26) local mult=far and 0.73 or 1.22 frame:drawPixel(x,y,app.pixelColor.rgba(math.min(255,math.floor(r*mult)),math.min(255,math.floor(g*mult)),math.min(255,math.floor(b*mult)),a)) end end end end for phase=0,1 do local index=col*2+phase local shifted=Image(48,64,ColorMode.RGB) local bob=(col%2==1 and phase==0) and -1 or 0 shifted:drawImage(frame,Point(0,bob)) if bob~=0 then local bottom=-1 for pixel in frame:pixels() do if app.pixelColor.rgbaA(pixel())>0 then bottom=math.max(bottom,pixel.y) end end for x=0,47 do shifted:drawPixel(x,bottom,frame:getPixel(x,bottom)) end end for y=0,63 do for x=0,47 do atlas:drawPixel(index*48+x,row*64+y,shifted:getPixel(x,y)) end end end end end local out=Sprite(384,256,ColorMode.RGB);out.cels[1].image=atlas out:saveAs(app.params.output);out:close()