-- Minor native-pixel contact cleanup of existing selected art. -- No resizing or head/torso replacement. Preserve original atlases as history. local sprite=app.open(app.params.source) local original=Image(sprite.cels[1].image) local out=Image(original) local columns=math.floor(original.width/48) local function put(x,y,c) out:drawPixel(x,y,c) end if app.params.character=='surly' then -- Correct duplicated support phases in front/back views. Only hands and -- lower robe/legs exchange sides; chest wrap, belt, head and neck stay fixed. for _,row in ipairs({0,3}) do for col=math.floor(columns/2),columns-1 do local ref=col-math.floor(columns/2) for y=35,63 do for x=9,38 do if y>=45 or (x<18 or x>29) then put(col*48+x,row*64+y,original:getPixel(ref*48+47-x,row*64+y)) end end end end end end -- Remove rounded toe-cap lighting from rear boots; use a dark heel block, -- muted vertical back seam and flat sole. Work within existing opaque pixels. for col=0,columns-1 do for _,span in ipairs({{16,23},{24,32}}) do local bottom=-1 for y=51,63 do for x=span[1],span[2] do if app.pixelColor.rgbaA(out:getPixel(col*48+x,192+y))>0 then bottom=math.max(bottom,y) end end end if bottom>=54 then local left,right=48,-1 for x=span[1],span[2] do if app.pixelColor.rgbaA(out:getPixel(col*48+x,192+bottom-1))>0 then left=math.min(left,x);right=math.max(right,x) end end if right>=left then local centre=math.floor((left+right)/2) for y=bottom-3,bottom do for x=left,right do local c=out:getPixel(col*48+x,192+y) if app.pixelColor.rgbaA(c)>0 then local r,g,b=app.pixelColor.rgbaR(c),app.pixelColor.rgbaG(c),app.pixelColor.rgbaB(c) local mult=y==bottom and 0.5 or 0.72 local seam=(x==centre and y