Advertisement
LDDestroier

pue demo

Dec 7th, 2017
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. --demo for pue (paintutils extra)
  2. -- pastebin get weLUU423 puedemo
  3. if not fs.exists("pue") then
  4.     print("Downloading PUE...")
  5.     local file = fs.open(fs.combine(fs.getDir(shell.getRunningProgram()),"pue"),"w")
  6.     file.write(http.get("https://pastebin.com/raw/7XAmsAbX").readAll())
  7.     file.close()
  8. end
  9. shell.run("pue")
  10.  
  11. local tArg = {...}
  12. local image = tArg[1] and paintutils.autocrop(paintutils.loadImage(tArg[1])) or {{32,32,32,32,32,32,512,512,512,512,512},{32,8192,32,8192,32,8192,2048,2048,512,512,512},{32,8192,8192,8192,32,32,2048,512,512,512,512},{32,8192,32,8192,32,8192,2048,2048,512,2048,512},{32,32,32,32,32,32,512,512,512,512,512}}
  13.  
  14. local mon = peripheral.find("monitor")
  15. if mon then mon.setTextScale(0.5) end
  16. local scr_x,scr_y = term.getSize()
  17.  
  18. --scale image down to highest effective resolution
  19.  
  20. local imgXsize, imgYsize = paintutils.getSize(image)
  21. if imgXsize > scr_x or imgYsize > scr_y then
  22.     if imgXsize < imgYsize then
  23.         image = paintutils.stretchImage(image,scr_x,imgYsize*(scr_x/imgXsize))
  24.     else
  25.         image = paintutils.stretchImage(image,imgXsize*(scr_y/imgYsize),scr_y)
  26.     end
  27. end
  28.  
  29. local fliptest = function()
  30.     local buffer = 1
  31.     local bg = paintutils.fullScreen(colors.black)
  32.     local img
  33.     local objectX,objectY,objectXspeed,objectYspeed = 2, 2, 1, 1
  34.     local objImg
  35.     local objSizeX,objSizeY = 13, 10
  36.     while true do
  37.         buffer = (buffer + 0.05) % 360
  38.         if (objectX >= scr_x-objSizeX) or (objectX <= 1) then
  39.             objectXspeed = objectXspeed * -1
  40.         end
  41.         if (objectY >= scr_y-objSizeY) or (objectY <= 1) then
  42.             objectYspeed = objectYspeed * -1
  43.         end
  44.         objectX = objectX + objectXspeed
  45.         objectY = objectY + objectYspeed
  46.        
  47.         local bigImgScaleX = math.sin(buffer)*(scr_x-2)
  48.         local bigImgScaleY = math.cos(buffer/3)*(scr_y-2)
  49.        
  50.         local bigImage = paintutils.centerWithBlankSpace(paintutils.stretchImage(image,bigImgScaleX,bigImgScaleY))
  51.         objImg = paintutils.stretchImage(image,math.cos(buffer*4)*objSizeX,objSizeY)
  52.         img = paintutils.merge({objImg,objectX,objectY}, {bigImage,1,1}, {bg,1,1})
  53.         paintutils.drawImageBlit(img,1,1)
  54.         sleep(0.05)
  55.     end
  56. end
  57.  
  58. fliptest()
  59.  
  60. --1+(scr_x/2)-math.abs(bigImgScaleX/2),1+(scr_y/2)-math.abs(bigImgScaleY/2) --old math for centering big image
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement