Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Circle Loading Animation, By Symmetryc
- -- # Configuration # --
- local back_color = colors.white
- local dither_color = colors.lightBlue
- local dither_char = "#"
- local dither_len = 10
- local solid_color = colors.lightBlue
- local solid_len = dither_len * 3
- local speed = 7
- local radius = 10
- local thickness = 2
- local size_x, size_y = term.getSize()
- local center_x, center_y = size_x / 2, size_y / 2
- local y_comp = 2 / 3
- local text = "<Loading Text>"
- local text_color = colors.cyan
- local text_back = back_color
- local text_x, text_y = center_x - #text / 2, center_y
- -- # Code # --
- local x, y, n
- local sin, cos = math.sin, math.cos
- local pi = math.pi
- local up = math.ceil
- local draw_pixel = function(back, text, char, from, to)
- term.setBackgroundColor(back)
- term.setTextColor(text)
- for i = from, to do
- n = pi * i / 180
- for j = radius, radius + thickness do
- x = center_x + j * sin(n)
- y = center_y + j * y_comp * cos(n)
- term.setCursorPos(up(x > center_x and x - 1 or x), up(y))
- term.write(char)
- end
- end
- end
- term.setBackgroundColor(back_color)
- term.clear()
- term.setCursorPos(up(text_x), up(text_y))
- term.setTextColor(text_color)
- term.setBackgroundColor(text_back)
- term.write(text)
- local inc
- while true do
- for i = 1, 360, speed do
- draw_pixel(back_color, back_color, " ", i - speed, i)
- inc = i
- draw_pixel(back_color, dither_color, dither_char, inc + 1, inc + dither_len)
- inc = inc + dither_len
- draw_pixel(solid_color, solid_color, " ", inc + 1, inc + solid_len)
- inc = inc + solid_len
- draw_pixel(back_color, dither_color, dither_char, inc + 1, inc + dither_len)
- os.queueEvent("circle")
- os.pullEvent("circle")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement