Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[local function getY( centerx, centery, radius, x )
- local origin = math.sqrt( radius^2 - (x - centerx) ^2 )
- return math.floor(centery + origin), math.floor(centery - origin)
- end
- ]]
- local tCircles = {}
- local function drawCircle( centerX, centerY, radius, col, solid )
- solid = solid or false
- local isAdvanced = term.isColor and term.isColor()
- local char = isAdvanced and " " or "|"
- if isAdvanced then term.setBackgroundColor( col ) end
- local radStep = 1/(1.5*radius)
- for angle = 1, math.pi+radStep, radStep do
- local pX = math.cos( angle ) * radius * 1.5
- local pY = math.sin( angle ) * radius
- if solid then
- local chord = 2*math.abs(pX)
- term.setCursorPos( centerX - chord/2, centerY - pY )
- write( char:rep( chord ) )
- term.setCursorPos( centerX - chord/2, centerY + pY )
- write( char:rep( chord ) )
- else
- for i=-1,1,2 do
- for j=-1,1,2 do
- term.setCursorPos( centerX + i*pX, centerY + j*pY )
- write( char )
- end
- end
- end
- end
- end
- local tWindows = { ["term"] = window.create( term.current(), 1, 1, term.getSize() ) }
- local id = os.startTimer( 0.1 )
- while true do
- local event = { os.pullEvent() }
- if event[ 1 ] == "mouse_click" then
- tCircles[ #tCircles + 1 ] = { parent = "term", r = 1, x = event[ 3 ], y = event[ 4 ] }
- elseif event[ 1 ] == "monitor_touch" then
- if not tWindows[ event[ 2 ] ] then
- peripheral.call( event[ 2 ], "setTextScale", 0.5 )
- tWindows[ event[ 2 ] ] = window.create( peripheral.wrap( event[ 2 ] ), 1, 1, peripheral.call( event[ 2 ], "getSize" ) )
- end
- tCircles[ #tCircles + 1 ] = { parent = event[ 2 ], r = 1, x = event[ 3 ], y = event[ 4 ] }
- elseif event[ 1 ] == "timer" and event[ 2 ] == id then
- id = os.startTimer( 0.1 )
- for k, v in pairs( tWindows ) do
- v.setVisible( false )
- v.setBackgroundColor( colors.lightBlue )
- v.clear()
- end
- local origin = term.current()
- for i, circle in pairs( tCircles ) do
- local t = tWindows[ circle.parent ]
- local maxx, maxy = t.getSize()
- term.redirect( t )
- --[[
- for x = 1, maxx, 0.75 / circle.r do
- local y1, y2 = getY( circle.x, circle.y, circle.r, x )
- t.setCursorPos( x, y1 )
- t.write( " " )
- t.setCursorPos( x, y2 )
- t.write( " " )
- end
- ]]--
- drawCircle( circle.x, circle.y, circle.r, colors.blue, false )
- circle.r = circle.r + 1
- if circle.r > ( maxx / 2 ) then
- table.remove( tCircles, i )
- end
- end
- term.redirect( origin )
- for _, v in pairs( tWindows ) do
- v.setVisible( true )
- v.redraw()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement