Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 0 0
  1. --[[
  2. basically draws an image with
  3.  
  4. aaa bbb aaa bbb ...
  5. ccc bbb ccc bbb
  6. aaa bbb aaa bbb
  7. ccc bbb ccc bbb
  8. aaa bbb aaa bbb
  9. ccc bbb ccc bbb
  10. ...
  11.  
  12. if you know the luminance of a and c, and b columns blends in perfectly, then the luminance of b is the average of that of a and c
  13.  
  14. keys:
  15.  
  16. escape - quit
  17. f - toggle fullscreen. this is borderless windowed so it shouldn't overwrite any LUT you have loaded.
  18. q,a - increase/decrease a
  19. w,s - increase/decrease b
  20. e,d - increase/decrease c
  21. c,z - increase/decrease the precision of adjusting a,b,c
  22. x - swap columns
  23. t - change color to white
  24. r - red
  25. g - green
  26. b -blue
  27.  
  28. ]]
  29.  
  30. function love.load()
  31.     a = 0
  32.     b = 190
  33.     c = 255
  34.     p = 1
  35.     seed = 3.14159
  36.     col = 2
  37.     z = 0
  38.  
  39.     love.keyboard.setKeyRepeat(true)
  40.     love.graphics.setBackgroundColor(0, 0, 0)
  41.     love.window.setMode(1600,900,{resizable=true})
  42.     --love.window.setFullscreen(true, "desktop")
  43. end
  44.  
  45. function setcol(c)
  46.     if col == 0 then
  47.         love.graphics.setColor(c, c, c)
  48.     elseif col == 1 then
  49.         love.graphics.setColor(c, 0, 0)
  50.     elseif col == 2 then
  51.         love.graphics.setColor(0, c, 0)
  52.     elseif col == 3 then
  53.         love.graphics.setColor(0, 0, c)
  54.     end
  55. end
  56.  
  57. function love.draw()
  58.     math.randomseed(seed)
  59.     setcol(b)
  60.     for x = 100,1800,100 do
  61.         for y = 100, 1100 do
  62.             love.graphics.rectangle("fill", x+z*50, y, 49, 1)
  63.         end
  64.     end
  65.  
  66.     setcol(a)
  67.     for x = 150,1850,100 do
  68.         for y = 99,1100,2 do
  69.             love.graphics.rectangle("fill",x-z*50,y,49,1)
  70.         end
  71.     end
  72.    
  73.     setcol(c)
  74.     for x = 150,1850,100 do
  75.         for y = 100,1100,2 do
  76.             love.graphics.rectangle("fill",x-z*50,y,49,1)
  77.         end
  78.     end
  79.    
  80.     love.graphics.setColor(255, 255, 255)
  81.     love.graphics.print(a.." "..b.." "..c.." "..p, 100, 10)
  82. end
  83.  
  84. function love.keypressed(key)
  85. --lua y u no switch??
  86.     if key == 'q' then --increase/decrease colors
  87.         a = a + p
  88.     elseif key == 'a' then
  89.         a = a - p
  90.     elseif key == 'w' then
  91.         b = b + p
  92.     elseif key == 's' then
  93.         b = b - p
  94.     elseif key == 'e' then
  95.         c = c + p
  96.     elseif key == 'd' then
  97.         c = c - p
  98.  
  99.     elseif key == 'z' then --increase/decrease precision
  100.         p = p / 4
  101.     elseif key == 'c' then
  102.         p = p * 4
  103.  
  104.     elseif key == 't' then --change color
  105.         col = 0
  106.     elseif key == 'r' then
  107.         col = 1
  108.     elseif key == 'g' then
  109.         col = 2
  110.     elseif key == 'b' then
  111.         col = 3
  112.  
  113.     elseif key == 'x' then --swap columns
  114.         z = 1 - z
  115.  
  116.     elseif key == "f" then
  117.         love.window.setFullscreen(not love.window.getFullscreen( ), "desktop")
  118.     elseif key == 'escape' then
  119.         love.event.quit()
  120.     end
  121.    
  122.     if a > 255 then a = 255
  123.     elseif a < 0 then a = 0 end
  124.     if b > 255 then b = 255
  125.     elseif b < 0 then b = 0 end
  126.     if c > 255 then c = 255
  127.     elseif c < 0 then c = 0 end
  128.    
  129.     if p > 64 then p = 64
  130.     elseif p < 1/64 then p = 1/64 end
  131.  
  132.     seed = math.random()
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement