Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile("ccLIB")
- function round(num,idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- clear()
- printC("Circle")
- nl()
- nl()
- write("Radius: ")
- rinput = read()
- radius = tonumber(rinput)
- _max = radius*2+1
- plot = {}
- for i=1,_max do
- plot[i] = {}
- for j=1,_max do
- plot[i][j] = 0
- end
- end
- angle = 0
- step = 64
- --print(_max)
- --getKey()
- while angle <= 2 * math.pi do
- x_cord = round(math.sin(angle)*radius+radius,0)
- y_cord = round(math.cos(angle)*radius+radius,0)
- plot[x_cord+1][y_cord+1] = 1
- --print("("..x_cord..","..y_cord..")")
- --getKey()
- angle = angle + (math.pi / step)
- end
- turtle.turnRight()
- turtleBack(radius)
- turtle.turnLeft()
- turtleBack(radius)
- for c=1,_max do
- for i=1,_max do
- if plot[c][i] == 1 then
- turtle.placeDown()
- end
- turtleForward()
- end
- turtle.turnRight()
- turtleForward()
- turtle.turnLeft()
- turtleBack(_max)
- end
Add Comment
Please, Sign In to add comment