local ____exports = {}
local getChargeBarClamp
function getChargeBarClamp(self, charges, maxCharges)
    local meterMultiplier = 24 / maxCharges
    local meterClip = 26 - charges * meterMultiplier
    return Vector(0, meterClip)
end
local CHARGE_BAR_ANM2 = "gfx/ui/ui_chargebar.anm2"
--- Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
-- helper function.
-- 
-- Note that this is for the vertical charge bar that represents the number of charges that an
-- active item has, not the circular charge bar that shows e.g. the charge rate of Brimstone.
function ____exports.newChargeBarSprites(self, maxCharges)
    local back = Sprite()
    back:Load(CHARGE_BAR_ANM2, true)
    back:Play("BarEmpty", true)
    local meter = Sprite()
    meter:Load(CHARGE_BAR_ANM2, true)
    meter:Play("BarFull", true)
    local meterBattery = Sprite()
    meterBattery:Load(CHARGE_BAR_ANM2, true)
    meterBattery:Play("BarFull", true)
    local lines = Sprite()
    lines:Load(CHARGE_BAR_ANM2, true)
    lines:Play(
        "BarOverlay" .. tostring(maxCharges),
        true
    )
    return {
        back = back,
        meter = meter,
        meterBattery = meterBattery,
        lines = lines,
        maxCharges = maxCharges
    }
end
--- Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
-- function to initialize the sprites, and then call this function on every render frame.
-- 
-- Note that this is for the vertical charge bar that represents the number of charges that an
-- active item has, not the circular charge bar that shows e.g. the charge rate of Brimstone.
function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
    sprites.back:Render(position)
    local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
    sprites.meter:Render(position, normalChargesClamp)
    local batteryChargesClamp = getChargeBarClamp(nil, batteryCharges, sprites.maxCharges)
    sprites.meterBattery:Render(position, batteryChargesClamp)
    sprites.lines:Render(position)
end
return ____exports
