local addon, ns = ...
local ss = ns.SS

local setmetatable = setmetatable

local mtFilling = {};

function mtFilling:New(parent,size,c,t,t2,c2, displayMode)
  size = (displayMode and displayMode == "preview") and 150 or size

  if c2 then
    if not t2 then
      local split = ss.FillTextures.get("split", 1)
      t, t2 = split[1], split[2]
    end

    local fillingLeft = parent:CreateTexture(nil,"BACKGROUND")
    fillingLeft:SetTexture(t)
    fillingLeft:SetPoint("BOTTOMLEFT",(size * 0.03)/2,size * 0.025)
    fillingLeft:SetWidth((size * 0.95) / 2)
    fillingLeft:SetHeight(size * 0.95)
    fillingLeft:SetAlpha(1)
    fillingLeft:SetVertexColor(ss:GetRGBAValues(c))

    local fillingRight = parent:CreateTexture(nil, "BACKGROUND")
    fillingRight:SetTexture(t2)
    fillingRight:SetPoint("BOTTOMRIGHT",(size * -0.03)/2,size * 0.025)
    fillingRight:SetWidth((size * 0.95) / 2)
    fillingRight:SetHeight(size * 0.95)
    fillingRight:SetAlpha(1)
    fillingRight:SetVertexColor(ss:GetRGBAValues(c2))

    return fillingLeft, fillingRight
  else
    if t2 then
      t = ss.FillTextures.get("primary","moon")
    end

    local filling = parent:CreateTexture(nil,"BACKGROUND")
    filling:SetTexture(t)
    filling:SetPoint("BOTTOM",0,size * -0.043)
    filling:SetWidth(size * 1.086)
    filling:SetHeight(size * 1.086)
    filling:SetAlpha(1)
    filling:SetVertexColor(ss:GetRGBAValues(c))

    return filling
  end
end

ss["FillingCreator"] = setmetatable({}, { __index = mtFilling });