Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sin45 = 0.70710678118
- function max(tab)
- local n = 0
- for k,v in pairs(tab) do
- if v>n then
- n=v
- end
- end
- return n
- end
- function getSlice(r)
- local cap = r*sin45
- local rs = r^2
- local ptab = {}
- for i=cap,r,0.1 do
- local val = math.sqrt(rs - i^2)
- if not ptab[i] then
- ptab[i] = val
- elseif val > ptab[i] then
- ptab[i] = val
- end
- end
- return ptab
- end
- function getQuarter(r)
- local slice = getSlice(r)
- local ptab = {}
- for k,v in pairs(slice) do
- ptab[k]=v
- ptab[v]=k
- end
- return ptab
- end
- function getHalf(r)
- local quarter = getQuarter(r)
- local ptab = {}
- for k,v in pairs(quarter) do
- ptab[k]=v
- ptab[-k]=v
- end
- return ptab
- end
- function drawCircle(ptab,ofx,ofy,sc)
- term.setBackgroundColor(colors.white)
- for k,v in pairs(ptab) do
- local cx = 0
- local cy = sc and k*(2/3) or k
- cy = math.floor(cy)
- term.setCursorPos(cx+ofx,cy+ofy)
- term.write(string.rep(" ",v))
- term.setCursorPos(ofx-v+1,cy+ofy)
- term.write(string.rep(" ",v))
- end
- local len = max(ptab)
- --if len>10 then len = len + 1 end
- term.setCursorPos(ofx-len+1,ofy-1)
- term.write(string.rep(" ",len*2-1))
- term.setCursorPos(ofx-len+1,ofy)
- term.write(string.rep(" ",len*2-1))
- term.setBackgroundColor(colors.black)
- end
- local tArgs = {...}
- local rz = 5
- local scc = false
- if tArgs[1] and tonumber(tArgs[1]) then
- rz = tArgs[1]
- end
- if tArgs[2] then
- scc=tArgs[2]
- end
- local tx,ty = term.getSize()
- drawCircle(getHalf(rz),math.floor(tx/2)+1,math.floor(ty/2)+1,scc)
- os.pullEvent()
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement