Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. --Background by Cheeseot--
  2. local dots = {}
  3. local menuref = gui.Reference("MENU")
  4. local groupref = gui.Reference("SETTINGS","Miscellaneous")
  5. local oldx, oldy = menuref:GetValue()
  6. local movex, movey = 0,0
  7. gui.Text(groupref, " ")
  8. local dotsizeslider = 3.5
  9. local dotsize = 3.5
  10. local dotamountslider = 250
  11. local amount = 250
  12. local dotspeedslider = 250
  13. local speed, oldspeed = 8, 8
  14. local minspeedslider = 1
  15. local minspeed, oldminspeed = 1, 1
  16. local dotcolor = gui.ColorEntry( "dotcolor", "Background Dot Color", 255, 255, 255, 130 )
  17. local linecolor = gui.ColorEntry( "linecolor", "Background Line Color", 255, 255, 255, 65)
  18. local fadecolor = gui.ColorEntry( "fadecolor", "Background Fade Color", 0, 0, 0, 125)
  19. local w,h = 1920,1080
  20. local menux, menuy, menusizex, menusizey, scale = 0, 0, 800, 600, 1
  21. local solidmenu = 1
  22. local constantspeed = 1
  23. local framerate = 0.0
  24.  
  25. local function getfps()
  26. local framerate = 0.9 * framerate + (1.0 - 0.9) * globals.AbsoluteFrameTime()
  27. return math.floor((1.0 / framerate) + 0.5)
  28. end
  29.  
  30. local function screensize()
  31.  
  32. w,h = draw.GetScreenSize()
  33.  
  34. end
  35.  
  36. callbacks.Register("Draw",screensize)
  37.  
  38. local function randompos()
  39.  
  40. for _,dot in ipairs(dots) do
  41.  
  42. ::start::
  43.  
  44. local posx = math.random(w)
  45. local posy = math.random(h)
  46.  
  47. if solidmenu:GetValue() then
  48. if not (posx > menux and posx < menux + menusizex and posy > menuy and posy < menuy + menusizey) then
  49.  
  50. dot[1] = posx
  51. dot[2] = posy
  52.  
  53. else
  54. goto start
  55. end
  56. else
  57.  
  58. dot[1] = posx
  59. dot[2] = posy
  60.  
  61. end
  62. end
  63. end
  64.  
  65. local randombutton = randompos
  66.  
  67. local function distance(w1,h1,w2,h2)
  68.  
  69. local dist = math.sqrt((w2 - w1)^2 + (h2 - h1)^2)
  70. return dist
  71.  
  72. end
  73.  
  74. --Background by Cheeseot--
  75.  
  76. local function inRect(x,y,x1,y1,x2,y2)
  77.  
  78. if x >= x1 and x <= x2 then
  79.  
  80. if y >= y1 and y <= y2 then
  81.  
  82. return true
  83.  
  84. else
  85.  
  86. return false
  87. end
  88.  
  89. else
  90.  
  91. return false
  92. end
  93. end
  94.  
  95. local function background()
  96.  
  97. if menuref:IsActive() then
  98.  
  99. dotsize = 3.5
  100. amount = math.floor(250)
  101. dotamountslider = amount
  102. speed = math.floor(100)
  103. dotspeedslider = speed
  104. minspeed = math.floor(1)
  105.  
  106. if speed < minspeed then
  107.  
  108. minspeed = speed
  109.  
  110. end
  111.  
  112. minspeedslider = minspeed
  113.  
  114. local liner,lineg,lineb,linea = linecolor:GetValue()
  115.  
  116. scale = gui.GetValue("dpi_Scale")
  117. menusizex = 800 * scale
  118. menusizey = 600 * scale
  119. menux,menuy = menuref:GetValue()
  120.  
  121. if oldx ~= menux or oldy ~= menuy then
  122.  
  123. movex = math.abs(menux - oldx)
  124. movey = math.abs(menuy - oldy)
  125. oldx, oldy = menux, menuy
  126.  
  127. elseif oldx == menux and oldy == menuy then
  128.  
  129. movex = 1
  130. movey = 1
  131.  
  132. end
  133.  
  134. while #dots < amount do
  135.  
  136. local posx = math.random(w)
  137. local posy = math.random(h)
  138.  
  139. if solidmenu:GetValue() then
  140.  
  141. if not (posx > menux and posx < menux + menusizex and posy > menuy and posy < menuy + menusizey) then
  142.  
  143. local velx,vely = 0,0
  144. local velxm,velym = 0.01,0.01
  145. local rand = math.random(1,4)
  146.  
  147. if speed == 0 then
  148.  
  149. velx = 0
  150. vely = 0
  151.  
  152. else
  153.  
  154. if rand == 1 then
  155.  
  156. velx = math.random(minspeed, speed * 10)/1000
  157. vely = math.random(minspeed, speed * 10)/1000
  158.  
  159. elseif rand == 2 then
  160.  
  161. velx = -1*(math.random(minspeed, speed * 10)/1000)
  162. vely = math.random(minspeed, speed * 10)/1000
  163.  
  164. elseif rand == 3 then
  165.  
  166. velx = math.random(minspeed, speed * 10)/1000
  167. vely = -1*(math.random(minspeed, speed * 10)/1000)
  168.  
  169. elseif rand == 4 then
  170.  
  171. velx = -1*(math.random(minspeed, speed * 10)/1000)
  172. vely = -1*(math.random(minspeed, speed * 10)/1000)
  173.  
  174. end
  175. end
  176.  
  177. local dot = {posx, posy, velx, vely, velxm, velym}
  178.  
  179. table.insert(dots, dot)
  180.  
  181. end
  182.  
  183. else
  184.  
  185. local velx,vely = 0,0
  186. local velxm,velym = 0.01,0.01
  187. local rand = math.random(1,4)
  188.  
  189. if speed == 0 then
  190.  
  191. velx = 0
  192. vely = 0
  193.  
  194. else
  195.  
  196. if rand == 1 then
  197.  
  198. velx = math.random(minspeed, speed * 10)/1000
  199. vely = math.random(minspeed, speed * 10)/1000
  200.  
  201. elseif rand == 2 then
  202.  
  203. velx = -1*(math.random(minspeed, speed * 10)/1000)
  204. vely = math.random(minspeed, speed * 10)/1000
  205.  
  206. elseif rand == 3 then
  207.  
  208. velx = math.random(minspeed, speed * 10)/1000
  209. vely = -1*(math.random(minspeed, speed * 10)/1000)
  210.  
  211. elseif rand == 4 then
  212.  
  213. velx = -1*(math.random(minspeed, speed * 10)/1000)
  214. vely = -1*(math.random(minspeed, speed * 10)/1000)
  215.  
  216. end
  217. end
  218.  
  219. local dot = {posx, posy, velx, vely, velxm, velym}
  220.  
  221. table.insert(dots, dot)
  222.  
  223. end
  224. end
  225.  
  226. while #dots > amount do
  227.  
  228. table.remove(dots, 1)
  229.  
  230. end
  231.  
  232. if oldspeed ~= speed or oldminspeed ~= minspeed then
  233.  
  234. for _,dot in ipairs(dots) do
  235.  
  236. if dot[3] < 0 then
  237.  
  238. dot[3] = -1*(math.random(minspeed, speed * 10)/1000)
  239.  
  240. elseif dot[3] > 0 then
  241.  
  242. dot[3] = (math.random(minspeed, speed * 10)/1000)
  243.  
  244. else
  245.  
  246. local randx = math.random(2)
  247.  
  248. if randx == 1 then
  249.  
  250. dot[3] = (math.random(minspeed, speed * 10)/1000)
  251.  
  252. else
  253.  
  254. dot[3] = -1*(math.random(minspeed, speed * 10)/1000)
  255.  
  256. end
  257. end
  258.  
  259. if dot[4] < 0 then
  260.  
  261. dot[4] = -1*(math.random(minspeed, speed * 10)/1000)
  262.  
  263. elseif dot[4] > 0 then
  264.  
  265. dot[4] = (math.random(minspeed, speed * 10)/1000)
  266.  
  267. else
  268.  
  269. local randy = math.random(1,2)
  270.  
  271. if randy == 1 then
  272.  
  273. dot[4] = (math.random(minspeed, speed * 10)/1000)
  274.  
  275. else
  276.  
  277. dot[4] = -1*(math.random(minspeed, speed * 10)/1000)
  278.  
  279. end
  280. end
  281. end
  282.  
  283. oldspeed = speed
  284. oldminspeed = minspeed
  285.  
  286. end
  287.  
  288. draw.Color(fadecolor:GetValue())
  289. draw.FilledRect(0,0,w,h)
  290.  
  291. --Background by Cheeseot--
  292.  
  293. local mousex, mousey = input.GetMousePos()
  294.  
  295. for _,dot in ipairs(dots) do
  296.  
  297. if dot[5] > 0.01 then
  298. dot[5] = dot[5] * 0.99
  299. else
  300. dot[5] = 0.01
  301. end
  302.  
  303. if dot[6] > 0.01 then
  304. dot[6] = dot[6] * 0.99
  305. else
  306. dot[6] = 0.01
  307. end
  308.  
  309. if dot[1] >= w or dot[1] <= 0 then
  310. dot[3] = dot[3] * -1
  311. dot[5] = dot[5] * 0.9
  312. dot[6] = dot[6] * 0.9
  313. end
  314.  
  315. if dot[2] >= h or dot[2] <= 0 then
  316. dot[4] = dot[4] * -1
  317. dot[5] = dot[5] * 0.9
  318. dot[6] = dot[6] * 0.9
  319. end
  320.  
  321. if dot[1] > w then
  322. dot[1] = w
  323. end
  324.  
  325. if dot[1] < 0 then
  326. dot[1] = 0
  327. end
  328.  
  329. if dot[2] > h then
  330. dot[2] = h
  331. end
  332.  
  333. if dot[2] < 0 then
  334. dot[2] = 0
  335. end
  336.  
  337. if solidmenu:GetValue() then
  338.  
  339. if inRect(dot[1], dot[2], menux - 5, menuy - 4, menux + 20, menuy + menusizey + 4) then
  340.  
  341. dot[3] = dot[3] * -1
  342. dot[5] = dot[5] * 0.9
  343. dot[6] = dot[6] * 0.9
  344.  
  345. end
  346.  
  347. if inRect(dot[1], dot[2], menux + menusizex - 20, menuy - 4, menux + menusizex + 5, menuy + menusizey + 4) then
  348.  
  349. dot[3] = dot[3] * -1
  350. dot[5] = dot[5] * 0.9
  351. dot[6] = dot[6] * 0.9
  352.  
  353. end
  354.  
  355. if inRect(dot[1], dot[2], menux - 4, menuy - 5, menux + menusizex + 4, menuy + 20) then
  356.  
  357. dot[4] = dot[4] * -1
  358. dot[5] = dot[5] * 0.9
  359. dot[6] = dot[6] * 0.9
  360.  
  361. end
  362.  
  363. if inRect(dot[1], dot[2], menux - 4, menuy + menusizey - 20, menux + menusizex + 4, menuy + menusizey + 5) then
  364.  
  365. dot[4] = dot[4] * -1
  366. dot[5] = dot[5] * 0.9
  367. dot[6] = dot[6] * 0.9
  368.  
  369. end
  370.  
  371. if inRect(dot[1], dot[2], menux - 5, menuy - 5, menux + menusizex + 5, menuy + menusizey + 5) then
  372.  
  373. if dot[1] - (menux - 5) < (menux + menusizex + 5) - dot[1] and
  374. dot[1] - (menux - 5) < dot[2] - (menuy - 5) and
  375. dot[1] - (menux - 5) < (menuy + menusizey + 5) - dot[2] then
  376.  
  377. dot[1] = dot[1] - movex
  378.  
  379. if dot[5] < movex / 10 then
  380. dot[5] = movex / 10
  381. end
  382.  
  383. if dot[6] < movey / 10 then
  384. dot[6] = movey / 10
  385. end
  386. end
  387.  
  388. if (menux + menusizex + 5) - dot[1] < dot[1] - (menux - 5) and
  389. (menux + menusizex + 5) - dot[1] < dot[2] - (menuy - 5) and
  390. (menux + menusizex + 5) - dot[1] < (menuy + menusizey + 5) - dot[2] then
  391.  
  392. dot[1] = dot[1]+movex
  393.  
  394. if dot[5] < movex / 10 then
  395. dot[5] = movex / 10
  396. end
  397.  
  398. if dot[6] < movey / 10 then
  399. dot[6] = movey / 10
  400. end
  401. end
  402.  
  403. if dot[2] - (menuy - 5) < dot[1] - (menux - 5) and
  404. dot[2] - (menuy - 5) < (menux + menusizex + 5) - dot[1] and
  405. dot[2] - (menuy - 5) < (menuy + menusizey + 5) - dot[2] then
  406.  
  407. dot[2] = dot[2]-movey
  408.  
  409. if dot[6] < movey / 10 then
  410. dot[6] = movey / 10
  411. end
  412.  
  413. if dot[5] < movex / 10 then
  414. dot[5] = movex / 10
  415. end
  416. end
  417.  
  418. if (menuy + menusizey + 5) - dot[2] < dot[1] - (menux - 5) and
  419. (menuy + menusizey + 5) - dot[2] < (menux + menusizex + 5) - dot[1] and
  420. (menuy + menusizey + 5) - dot[2] < dot[2] - (menuy - 5)then
  421.  
  422. dot[2] = dot[2]+movey
  423.  
  424. if dot[6] < movey / 10 then
  425. dot[6] = movey / 10
  426. end
  427.  
  428. if dot[5] < movex / 10 then
  429. dot[5] = movex / 10
  430. end
  431. end
  432. end
  433. end
  434.  
  435. --Background by Cheeseot--
  436.  
  437. if constantspeed:GetValue() then
  438.  
  439. local fpsadjust = 600 / getfps()
  440.  
  441. if dot[3] > 0 then
  442.  
  443. dot[1] = dot[1] + (dot[3] + dot[5]) * fpsadjust
  444.  
  445. elseif dot[3] < 0 then
  446.  
  447. dot[1] = dot[1] + (dot[3] - dot[5]) * fpsadjust
  448.  
  449. end
  450.  
  451. if dot[4] > 0 then
  452.  
  453. dot[2] = dot[2] + (dot[4] + dot[6]) * fpsadjust
  454.  
  455. elseif dot[4] < 0 then
  456.  
  457. dot[2] = dot[2] + (dot[4] - dot[6]) * fpsadjust
  458.  
  459. end
  460. else
  461.  
  462. if dot[3] > 0 then
  463.  
  464. dot[1] = dot[1] + (dot[3] + dot[5])
  465.  
  466. elseif dot[3] < 0 then
  467.  
  468. dot[1] = dot[1] + (dot[3] - dot[5])
  469.  
  470. end
  471.  
  472. if dot[4] > 0 then
  473.  
  474. dot[2] = dot[2] + (dot[4] + dot[6])
  475.  
  476. elseif dot[4] < 0 then
  477.  
  478. dot[2] = dot[2] + (dot[4] - dot[6])
  479.  
  480. end
  481.  
  482. end
  483.  
  484. if math.abs(dot[1] - mousex) <= 150 and math.abs(dot[2] - mousey) <=150 then
  485.  
  486. local mousedist = distance(dot[1],dot[2],mousex,mousey)
  487.  
  488. if mousedist < 150 then
  489.  
  490. local fade = (255-(mousedist/1.5)*2.55)*((linea/255)*2)
  491.  
  492. if fade > 255 then
  493. fade = 255
  494. end
  495.  
  496. draw.Color(liner,lineg,lineb,fade)
  497. draw.Line(dot[1],dot[2],mousex,mousey)
  498.  
  499. --if mousedist < 25 then
  500. --dot[5] = math.random(3,5)
  501. --dot[6] = math.random(3,5)
  502. --end
  503. end
  504. end
  505.  
  506. for __,compare in ipairs(dots) do
  507.  
  508. if dot[1] ~= compare[1] and dot[2] ~= compare[2] then
  509.  
  510. if math.abs(dot[1] - compare[1]) <= 150 and math.abs(dot[2] - compare[2]) <= 150 then
  511.  
  512. local dist = distance(dot[1],dot[2],compare[1],compare[2])
  513.  
  514. if dist < 150 then
  515.  
  516. local fade = (255-(dist/1.5)*2.55)*(linea/255)
  517.  
  518. draw.Color(liner,lineb,lineg,fade)
  519. draw.Line(dot[1],dot[2],compare[1],compare[2])
  520. end
  521. end
  522. end
  523. end
  524.  
  525. draw.Color(dotcolor:GetValue())
  526. draw.FilledCircle(dot[1],dot[2],dotsize)
  527.  
  528. end
  529. end
  530. end
  531.  
  532. callbacks.Register("Draw",background)
  533.  
  534. --Background by Cheeseot--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement