crosseyetoanaglyph.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. -- crosseye to anaglyph - from Paulo Silva, july 2012 - gpl licence
  2. ok,rbrc,rbcr,rbby,rbyb=inputbox("crosseye to anaglyph","rc",1,0,1,-1,"cr",0,0,1,-1,"by",0,0,1,-1,"yb",0,0,1,-1);
  3. w,h=getpicturesize()
  4. wm=math.floor(w/2)
  5. function grayscaleindexed(c)
  6. r,g,b=getcolor(c);return math.floor((b*11+r*30+g*59)/100);end
  7. for y=0,h-1,1 do
  8. statusmessage("step 1:".. (math.floor(y*100/h)) .."% " )
  9. waitbreak(0)
  10. for x=0,w-1,1 do
  11. u=getpicturepixel(x,y)
  12. k=grayscaleindexed(u)
  13. putpicturepixel(x,y,k)
  14. end;end
  15. for c=0,255,1 do setcolor(c,c,c,c);end
  16. for y=0,h-1,1 do
  17. statusmessage("step 2:".. (math.floor(y*100/h)) .."% " )
  18. waitbreak(0)
  19. for x=0,wm-1,1 do
  20. slt=getpicturepixel(x,y)
  21. srt=getpicturepixel(x+wm,y)
  22. k=(math.floor(slt/16))*16+(math.floor(srt/16))
  23. putpicturepixel(x,y,k)
  24. end;end
  25. for c1=0,15,1 do
  26. for c2=0,15,1 do
  27. c1b=math.floor((c1*255)/15)
  28. c2b=math.floor((c2*255)/15)
  29. if rbrc==1 then setcolor(c1*16+c2,c1b,c2b,c2b);end
  30. if rbcr==1 then setcolor(c1*16+c2,c2b,c1b,c1b);end
  31. if rbby==1 then setcolor(c1*16+c2,c2b,c2b,c1b);end
  32. if rbyb==1 then setcolor(c1*16+c2,c1b,c1b,c2b);end
  33. end;end
  34. finalizepicture()
  35. setpicturesize(wm,h)