In some boids implementations, you’ll start with a given direction, add a little offset to it, and then snap that back onto the circumference to get the new (unit vector) direction. This will give you a reasonably “nearby” direction without much effort.
The same idea might give you a reasonable generator, although maybe it would mostly get stuck near the border. In any case, something like (tested just a little):
local x, y = 0, 0 local Scale = 10 -- tune if necessary function RandomPointInCircle (radius) x, y = x + (2 \* math.random() - 1) \* Scale, y + (2 \* math.random() - 1) \* Scale local r = math.sqrt(x^2, y^2) if r \> radius then local scale = radius / r scale = scale \* (.8 + math.random() \* .2) -- Maybe this would avoid getting "stuck" x, y = x \* scale, y \* scale end return x, y end local circle = display.newCircle(0, 0, 15) local params = { time = 100 } timer.performWithDelay(150, function() local x, y = RandomPointInCircle(250) params.x, params.y = display.contentCenterX + x, display.contentCenterY + y transition.to(circle, params) end, 0)


