picturetosequencedrandombars.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. yclsz=16;xclsz0=4;xclsz1=32
  2. function INT(a)
  3. return(a-a%1)
  4. end
  5. function RND(tseed)
  6. tvl1=INT(tseed/256)
  7. tvl2=(((tseed%256)*256)+253)-(tseed*2)
  8. tseed=tseed%256+tvl1
  9. tvl2=tvl2-tseed
  10. while tvl2<0 do tvl2=tvl2+65537 end
  11. tvl2=tvl2%65536
  12. return tvl2
  13. end
  14. function BOXHEXC(tx1,ty1,tx2,ty2,tcl)
  15. tr1=(INT(tcl/65536))%256
  16. tg1=(INT(tcl/256))%256
  17. tb1=tcl%256
  18. for tx3=tx1,tx2,1 do
  19. set_rgb(tx3,ty1,tr1/255,tg1/255,tb1/255)
  20. set_rgb(tx3,ty2,tr1/255,tg1/255,tb1/255)
  21. end
  22. for ty3=ty1,ty2,1 do
  23. set_rgb(tx1,ty3,tr1/255,tg1/255,tb1/255)
  24. set_rgb(tx2,ty3,tr1/255,tg1/255,tb1/255)
  25. end
  26. end
  27. function BOXRGB(tx1,ty1,tx2,ty2,tr1,tg1,tb1)
  28. for tx3=tx1,tx2,1 do
  29. set_rgb(tx3,ty1,tr1/255,tg1/255,tb1/255)
  30. set_rgb(tx3,ty2,tr1/255,tg1/255,tb1/255)
  31. end
  32. for ty3=ty1,ty2,1 do
  33. set_rgb(tx1,ty3,tr1/255,tg1/255,tb1/255)
  34. set_rgb(tx2,ty3,tr1/255,tg1/255,tb1/255)
  35. end
  36. end
  37. function BARHEXC(tx1,ty1,tx2,ty2,tcl)
  38. tr1=(INT(tcl/65536))%256
  39. tg1=(INT(tcl/256))%256
  40. tb1=tcl%256
  41. for tx3=tx1,tx2,1 do
  42. for ty3=ty1,ty2,1 do
  43. set_rgb(tx3,ty3,tr1/255,tg1/255,tb1/255)
  44. end;end
  45. end
  46. function BARRGB(tx1,ty1,tx2,ty2,tr1,tg1,tb1)
  47. for tx3=tx1,tx2,1 do
  48. for ty3=ty1,ty2,1 do
  49. set_rgb(tx3,ty3,tr1/255,tg1/255,tb1/255)
  50. end;end
  51. end
  52. yclsz2=INT(yclsz/2)
  53. seed=0
  54. ycnt=0
  55. while ycnt<height do
  56. xcnt=0
  57. while xcnt<width do
  58. seed=RND(seed)
  59. xclsz=xclsz0+(seed%(xclsz1-xclsz0))
  60. xclsz2=INT(xclsz/2)
  61. x=xcnt+1
  62. y=ycnt+1
  63. r,g,b=get_rgb(x,y)
  64. BARRGB(xcnt,ycnt,xcnt+xclsz,ycnt+yclsz,r*255,g*255,b*255)
  65. xcnt=xcnt+xclsz
  66. end
  67. ycnt=ycnt+yclsz
  68. progress (ycnt/height)
  69. end