1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/shape/threaded_spirals.lua

22 lines
557 B
Lua
Raw Normal View History

2017-09-27 23:55:43 +02:00
-- Author: flowild
local arm_width = 96
local function is_on_spiral(x, y, distance, angle_offset)
2018-05-10 21:42:24 +02:00
local angle = angle_offset + math.deg(math.atan2(x, y))
2017-09-27 23:55:43 +02:00
local offset = distance
2018-05-10 21:42:24 +02:00
if angle ~= 0 then
offset = offset + angle / 3.75 * 2
end
2017-09-27 23:55:43 +02:00
return offset % 96 * 2 >= 48 * 2
end
2018-05-10 21:42:24 +02:00
return function(x, y, world)
local pseudo_x = x / (arm_width / 48)
local pseudo_y = y / (arm_width / 48)
local distance = math.sqrt(pseudo_x * pseudo_x + pseudo_y * pseudo_y)
return not (distance > 100 and not is_on_spiral(x, y, distance, 0))
2017-09-27 23:55:43 +02:00
end