Advertisement
Guest User

pic_ni_colourreducer_ql_halftone.lua

a guest
Jul 14th, 2012
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. -- cell colour reducer - sinclairql/bbcmicro - from Paulo Silva, july 2012 - gpl licence
  2. w,h=getpicturesize()
  3. ok,op1,op2,op3,op4,op5=inputbox("primary-clusters",
  4.       "cluster 1",1,0,1,-1,"cluster 2",0,0,1,-1,"cluster 3",0,0,1,-1,"cluster 4",0,0,1,-1,"cluster 5",0,0,1,-1);
  5. if ok==true then
  6.   if op1==1 then
  7.     ampl=5;clust={};clust[0+1]={0,1,2,3};clust[1+1]={2,3,0,1};clust[2+1]={0,1,2,3};clust[3+1]={2,3,0,1}
  8.     end
  9.   if op2==1 then
  10.     ampl=5;clust={};clust[0+1]={0,2,0,2};clust[1+1]={1,3,1,3};clust[2+1]={2,0,2,0};clust[3+1]={3,1,3,1}
  11.     end
  12.   if op3==1 then
  13.     ampl=3;clust={};clust[0+1]={0,1,0,1};clust[1+1]={1,0,1,0};clust[2+1]={0,1,0,1};clust[3+1]={1,0,1,0}
  14.     end
  15.   if op4==1 then
  16.     ampl=9;clust={};clust[0+1]={0,1,4,2};clust[1+1]={3,6,7,5};clust[2+1]={4,2,0,1};clust[3+1]={7,5,3,6}
  17.     end
  18.   if op5==1 then
  19.     ampl=17;clust={};clust[0+1]={00,12,03,15};clust[1+1]={08,04,11,07};clust[2+1]={02,14,01,13};clust[3+1]={10,06,09,05}
  20.     end
  21.   for y=0,h-1,1 do
  22.     for x=0,w-1,1 do
  23.       c=getpicturepixel(x,y)
  24.       r,g,b=getcolor(c)
  25.       patgf=math.floor(((1+clust[x%4+1][y%4+1])*255)/ampl)
  26.       c2=0
  27.       if b>patgf then c2=c2+1;end
  28.       if r>patgf then c2=c2+2;end
  29.       if g>patgf then c2=c2+4;end
  30.       putpicturepixel(x,y,c2)
  31.       end;end
  32.   for c=0,255,1 do setcolor(c,0,0,0);end
  33.   setcolor(1,0x00,0x00,0xFF);setcolor(2,0xFF,0x00,0x00);setcolor(3,0xFF,0x00,0xFF)
  34.   setcolor(4,0x00,0xFF,0x00);setcolor(5,0x00,0xFF,0xFF);setcolor(6,0xFF,0xFF,0x00)
  35.   setcolor(7,0xFF,0xFF,0xFF)
  36.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement