pictureoffset.lua 848 B

1234567891011121314151617181920212223
  1. -- picture offset - jul'12, from Paulo Silva
  2. -- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See <http://www.gnu.org/licenses/>
  3. w,h=getpicturesize()
  4. ok,xoff,yoff=inputbox("Picture Offset","x",w/2,0,w,0,"y",h/2,0,h,0);
  5. if ok==true then
  6. finalizepicture()
  7. setpicturesize(w,h*2)
  8. for y=0,h-1,1 do
  9. statusmessage("step 1:".. (math.floor(y*100/h)) .."% " )
  10. for x=0,w-1,1 do
  11. c=getpicturepixel(x,y)
  12. putpicturepixel((x+xoff)%w,h+((y+yoff)%h),c)
  13. end;end
  14. for y=0,h-1,1 do
  15. statusmessage("step 2:".. (math.floor(y*100/h)) .."% " )
  16. for x=0,w-1,1 do
  17. c=getpicturepixel(x,y+h)
  18. putpicturepixel(x,y,c)
  19. end;end
  20. finalizepicture()
  21. setpicturesize(w,h)
  22. end