8colourspercell.lua 988 B

12345678910111213141516171819202122232425262728293031323334353637
  1. xcell=8;ycell=8
  2. function INT(a)
  3. return(a-a%1)
  4. end
  5. for y=0,INT(height/ycell),1 do
  6. for x=0,INT(width/xcell),1 do
  7. rmin=255;rmax=0
  8. gmin=255;gmax=0
  9. bmin=255;bmax=0
  10. for y2=0,ycell-1,1 do
  11. for x2=0,xcell-1,1 do
  12. r,g,b=get_rgb(x*xcell+x2,y*ycell+y2)
  13. r=r*255;g=g*255;b=b*255
  14. if rmin>r then rmin=r end
  15. if gmin>g then gmin=g end
  16. if bmin>b then bmin=b end
  17. if rmax<r then rmax=r end
  18. if gmax<g then gmax=g end
  19. if bmax<b then bmax=b end
  20. end;end
  21. rmid=INT((rmax+rmin)/2)
  22. gmid=INT((gmax+gmin)/2)
  23. bmid=INT((bmax+bmin)/2)
  24. for y2=0,ycell,1 do
  25. for x2=0,xcell,1 do
  26. r,g,b=get_rgb(x*xcell+x2,y*ycell+y2)
  27. r=r*255;g=g*255;b=b*255
  28. r2=rmin;if r>rmid then r2=rmax end
  29. g2=gmin;if g>gmid then g2=gmax end
  30. b2=bmin;if b>bmid then b2=bmax end
  31. set_rgb(x*xcell+x2,y*ycell+y2,r2/255,g2/255,b2/255)
  32. end;end
  33. end
  34. progress((y*ycell)/height)
  35. end