-- sample usage: love . 5 3 5
local R = arg[2] and tonumber(arg[2]) or 3
local r = arg[3] and tonumber(arg[3]) or -1
local d = arg[4] and tonumber(arg[4]) or 0.5
local max_radius = R + math.abs(r) + d
local Rpx = R * 25
local rpx = r * 25
local dpx = d * 25
local x, y = max_radius * 25, max_radius * 25
local data = love.image.newImageData(1024, 1024)
for angle = 0, 360, 0.1 do
local x1 = Rpx * math.cos(angle * math.pi / 180)
local y1 = Rpx * math.sin(angle * math.pi / 180)
data:setPixel(x + x1, y + y1, 0, 0, 1, 1)
end
local img = love.graphics.newImage(data)
local angle = 0
function love.draw()
angle = angle - 1
local radius = (Rpx - rpx)
local x1 = radius * math.cos(angle * math.pi / 180)
local y1 = radius * math.sin(angle * math.pi / 180)
local xo, yo = x + x1, y + y1
data:setPixel(xo, yo, 1, 1, 1, 1)
local ratio = (1 - (R/r))
local x1 = dpx * math.cos(angle * ratio * math.pi / 180)
local y1 = dpx * math.sin(angle * ratio * math.pi / 180)
data:setPixel(xo + x1, yo + y1, 1, 0, 0, 1)
img:replacePixels(data)
love.graphics.draw(img, 0, 0, 0, 1, 1)
end
post a comment