Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawCircle(r,timeperc)
- --if you set the background and colors before calling the function
- --and remove the term.clear()
- --the clock will fill like a pie chart
- term.setBackgroundColor(colors.white);
- term.clear();
- term.setBackgroundColor(colors.black);
- term.setCursorBlink(false);
- linedrawn = false;
- sx,sy = term.getSize();
- sx = math.floor(sx/2);
- sy = math.floor(sy/2);
- --These numbers are to do with the number of radians the algorithim needs to cycle through to draw a complete circle
- --the offset is to make it start at the top of the screen
- for i = 4.67,7.18 + 4.67,0.01 do
- --circle plotting alogrithim
- plotx = sx+1 + r*math.cos(i) *1.6;
- ploty = sy+1 + r*math.sin(i);
- term.setCursorPos(plotx,ploty);
- --I cant figure out why I need 1.88 instead of 2, be nice and help me with this...
- perc = timeperc/1.88;
- if(i > (4.67 + perc * (7.18 + 4.67)) and linedrawn == false) then
- drawLine({sx,sy},{plotx,ploty});
- linedrawn = true;
- end
- term.write(" ");
- end
- end
- function drawLine(pt1,pt2)
- p = pt2[1];
- h = pt1[1];
- q = pt2[2];
- k = pt1[2];
- for i = 0,1,0.01 do
- x = (p-h)*i + h;
- y = (q - k)*i + k;
- term.setCursorPos(x,y);
- term.write(" ");
- end
- end
- term.redirect(peripheral.wrap("right"));
- while(true)do
- drawCircle(14,os.time()/24);
- os.sleep(0.0001);--to stop jittering
- end
- term.setCursorPos(1,1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement