local ffi = require("ffi")
local C = ffi.C
local core = require("pxl8.core")

local effects = {}

effects.GLOW_CIRCLE = 0
effects.GLOW_DIAMOND = 1
effects.GLOW_SHAFT = 2

function effects.glows(glows)
    if not glows or #glows == 0 then return end

    local count = #glows
    local glow_array = ffi.new("pxl8_glow_source[?]", count)

    for i, g in ipairs(glows) do
        local idx = i - 1
        glow_array[idx].x = g.x or 0
        glow_array[idx].y = g.y or 0
        glow_array[idx].radius = g.radius or 8
        glow_array[idx].intensity = g.intensity or 255
        glow_array[idx].color = g.color or 15
        glow_array[idx].depth = g.depth or 0xFFFF
        glow_array[idx].height = g.height or 0
        glow_array[idx].shape = g.shape or 0
    end

    C.pxl8_gfx_apply_effect(core.gfx, C.PXL8_GFX_EFFECT_GLOWS, glow_array, count)
end

return effects
