Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function putpixel(x,y)
- term.setCursorPos(x, y)
- term.write("@")
- end
- function drawCircle(x0,y0,radius)
- local x = radius-1
- local y = 0
- local dx = 1
- local dy = 1
- local err = dx - (bit.lshift(radius,1))
- while x >= y do
- putpixel(x0 + x, y0 + y)
- putpixel(x0 + y, y0 + x)
- putpixel(x0 - y, y0 + x)
- putpixel(x0 - x, y0 + y)
- putpixel(x0 - x, y0 - y)
- putpixel(x0 - y, y0 - x)
- putpixel(x0 + y, y0 - x)
- putpixel(x0 + x, y0 - y)
- if err <= 0 then
- y = y + 1
- err = err + dy;
- dy = dy + 2;
- if err > 0 then
- x = x - 1
- dx = dx + 2
- err = err + (bit.lshift(-radius,1)+dx)
- end
- end
- end
- drawCircle(10,10,10)
- read()
Advertisement
Add Comment
Please, Sign In to add comment