horizontaledgestretch.lua 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. leftempty=0;rightempty=0
  2. function INT(a)
  3. return(a-a%1)
  4. end
  5. function COPY(tx1,ty1,tx2,ty2,tx3,ty3)
  6. for ty4=ty1,ty2,1 do
  7. for tx4=tx1,tx2,1 do
  8. r,g,b=get_rgb(tx4,ty4)
  9. set_rgb(tx3+tx4-tx1,ty3+ty4-ty1,r,g,b)
  10. end;end
  11. end
  12. xver0=0
  13. for x=0,width-1,1 do
  14. r0,g0,b0=get_rgb(x,height*.33)
  15. r1,g1,b1=get_rgb(x,height*.66)
  16. if ((r0+g0+b0)~=(r1+g1+b1)) and leftempty==0 then
  17. xver0=x;leftempty=1
  18. end
  19. progress((x/width)*.25)
  20. end
  21. if leftempty==1 then
  22. for x=0,xver0-1,1 do
  23. COPY(xver0,0,xver0,height-1,x,0)
  24. progress(.25+((x/xver0)*.25))
  25. end;end
  26. xver1=0
  27. for x=width-1,0,-1 do
  28. r0,g0,b0=get_rgb(x,height*.33)
  29. r1,g1,b1=get_rgb(x,height*.66)
  30. if ((r0+g0+b0)~=(r1+g1+b1)) and rightempty==0 then
  31. xver1=x;rightempty=1
  32. end
  33. progress(.5+((width-x)/width)*.25)
  34. end
  35. if rightempty==1 then
  36. for x=xver1+1,width-1,1 do
  37. COPY(xver1,0,xver1,height-1,x,0)
  38. progress(.75+((x-xver1)/(width-xver1))*.25)
  39. end;end