amigaham.lua 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ham=4 -- ham=4 (ham6); ham=6 (ham8)
  2. function DIV(a,b)
  3. return(a-a%b)/b
  4. end
  5. function ABS(a)
  6. if a<0 then
  7. a=(a*-1.0)
  8. end
  9. return(a)
  10. end
  11. function INT(a)
  12. return(a-a%1)
  13. end
  14. for y=0,height-1,1 do
  15. ro=0;go=0;bo=0;pf=0;zo=0
  16. for x=0,width-1,1 do
  17. r,g,b=get_rgb(x,y)
  18. w=((b*11)+(r*30)+(g*59))/100
  19. r=r*255;g=g*255;b=b*255
  20. r2=r;g2=g;b2=b
  21. if ham==4 then
  22. b2=(INT(b/16))*255/15
  23. g2=(INT(g/16))*255/15
  24. r2=(INT(r/16))*255/15
  25. w2=(INT(w/16))*255/15
  26. end
  27. if ham==6 then
  28. b2=(INT(b/4))*255/63
  29. g2=(INT(g/4))*255/63
  30. r2=(INT(r/4))*255/63
  31. w2=(INT(w/4))*255/63
  32. end
  33. bd=ABS(b2-bo)
  34. rd=ABS(r2-ro)
  35. gd=ABS(g2-go)
  36. tg=0
  37. if bd>=rd and bd>=gd and tg==0 then
  38. bo=b2;pf=1;zo=bo;tg=1
  39. end
  40. if rd>=bd and rd>=gd and tg==0 then
  41. ro=r2;pf=2;zo=ro;tg=1
  42. end
  43. if gd>=rd and gd>=bd and tg==0 then
  44. go=g2;pf=3;zo=go;tg=1
  45. end
  46. set_rgb(x,y,ro/255,go/255,bo/255)
  47. end
  48. progress(y/height)
  49. end