Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. function drawCircle(r,timeperc)
  2. --if you set the background and colors before calling the function
  3. --and remove the term.clear()
  4. --the clock will fill like a pie chart
  5.  
  6. term.setBackgroundColor(colors.white);
  7. term.clear();
  8. term.setBackgroundColor(colors.black);
  9. term.setCursorBlink(false);
  10.  
  11. linedrawn = false;
  12.  
  13. sx,sy = term.getSize();
  14. sx = math.floor(sx/2);
  15. sy = math.floor(sy/2);
  16.  
  17. --These numbers are to do with the number of radians the algorithim needs to cycle through to draw a complete circle
  18. --the offset is to make it start at the top of the screen
  19.  
  20. for i = 4.67,7.18 + 4.67,0.01 do
  21.  
  22. --circle plotting alogrithim
  23. plotx = sx+1 + r*math.cos(i) *1.6;
  24. ploty = sy+1 + r*math.sin(i);
  25.  
  26. term.setCursorPos(plotx,ploty);
  27.  
  28. --I cant figure out why I need 1.88 instead of 2, be nice and help me with this...
  29. perc = timeperc/1.88;
  30. if(i > (4.67 + perc * (7.18 + 4.67)) and linedrawn == false) then
  31. drawLine({sx,sy},{plotx,ploty});
  32. linedrawn = true;
  33. end
  34.  
  35. term.write(" ");
  36.  
  37. end
  38. end
  39. function drawLine(pt1,pt2)
  40. p = pt2[1];
  41. h = pt1[1];
  42. q = pt2[2];
  43. k = pt1[2];
  44. for i = 0,1,0.01 do
  45. x = (p-h)*i + h;
  46. y = (q - k)*i + k;
  47. term.setCursorPos(x,y);
  48. term.write(" ");
  49. end
  50. end
  51. term.redirect(peripheral.wrap("right"));
  52. while(true)do
  53. drawCircle(14,os.time()/24);
  54. os.sleep(0.0001);--to stop jittering
  55. end
  56. term.setCursorPos(1,1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement