lenny45switch.lua 909 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. cellsz=8;ticknets=2
  2. function INT(a)
  3. return(a-a%1)
  4. end
  5. function BAR(tx1,ty1,tx2,ty2,tcl)
  6. tr1=(INT(tcl/65536))%256
  7. tg1=(INT(tcl/256))%256
  8. tb1=tcl%256
  9. for tx3=tx1,tx2,1 do
  10. for ty3=ty1,ty2,1 do
  11. set_rgb(tx3,ty3,tr1/255,tg1/255,tb1/255)
  12. end;end
  13. end
  14. function RND(tseed)
  15. tvl1=INT(tseed/256)
  16. tvl2=(((tseed%256)*256)+253)-(tseed*2)
  17. tseed=tseed%256+tvl1
  18. tvl2=tvl2-tseed
  19. while tvl2<0 do tvl2=tvl2+65537 end
  20. tvl2=tvl2%65536
  21. return tvl2
  22. end
  23. seed=0
  24. for x1=0,width-1,cellsz do
  25. for y1=0,height-1,cellsz do
  26. BAR(x1,y1,x1+cellsz-1,y1+cellsz-1,0xFFFFFF)
  27. seed=RND(seed)
  28. if (seed%256)>128 then
  29. for x2=0,cellsz-ticknets,1 do
  30. BAR(x1+x2,y1+x2,x1+x2+ticknets-1,y1+x2+ticknets-1,0x000000)
  31. end
  32. else
  33. for x2=0,cellsz-ticknets,1 do
  34. BAR(x1+x2,y1+cellsz-x2-2,x1+x2+ticknets-1,y1+cellsz-x2+ticknets-3,0x000000)
  35. end
  36. end
  37. end;end