Quantcast WoWInterface: SVN - hankui - Rev 14 - /Interface/AddOns/hankui/media/imaging.lua

WoWInterface SVN hankui

[/] [Interface/] [AddOns/] [hankui/] [media/] [imaging.lua] - Rev 14

Compare with Previous | Blame | View Log

setfenv(1, select(2, ...))
local cos, sin, rad, unpack = math.cos, math.sin, math.rad, unpack

local function RotateCoordPair(x, y, ox, oy, a, asp)
        y = y / asp
        oy = oy / asp
        return ox + (x - ox) * math.cos(a) - (y - oy) * math.sin(a),
                (oy + (y - oy) * math.cos(a) + (x - ox) * math.sin(a)) * asp
end

function SetRotatedTexCoords(tex, left, right, top, bottom, width, height, angle, originx, originy)
        local ratio, angle, originx, originy = width / height, math.rad(angle), originx or 0.5, originy or 1
        local LRx, LRy = RotateCoordPair(left, top, originx, originy, angle, ratio)
        local LLx, LLy = RotateCoordPair(left, bottom, originx, originy, angle, ratio)
        local ULx, ULy = RotateCoordPair(right, top, originx, originy, angle, ratio)
        local URx, URy = RotateCoordPair(right, bottom, originx, originy, angle, ratio)
        tex:SetTexCoord(LRx, LRy, LLx, LLy, ULx, ULy, URx, URy)
end

local tileSize, textures = 8, {
        "LEFT", "RIGHT", "TOP", "BOTTOM",
        "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT",
}

-- Adds an innerglow effect to the frame
function ApplyInnerGlow(frame)
        for i, v in ipairs(textures) do
                local texture = frame:CreateTexture()
                texture:SetDrawLayer("BACKGROUND", 1)
                texture:SetTexture("Interface\\AddOns\\hankui\\media\\borders\\dialoginnerglow")
                texture:SetVertexColor(unpack(colors["Signature color"]:GetTransparent(0.66)))
        
                if v == "TOP" or v == "BOTTOM" then
                        texture:SetPoint(v .. "LEFT", tileSize, 0)
                        texture:SetPoint(v .. "RIGHT", -tileSize, 0)
                        texture:SetHeight(tileSize)
                        SetRotatedTexCoords(texture, (i - 1) * 0.125, i * 0.125, 0, 1, tileSize * 8, tileSize, -90, i * 0.125, 1)
                elseif v == "LEFT" or v == "RIGHT" then
                        texture:SetPoint("TOP" .. v, 0, -tileSize)
                        texture:SetPoint("BOTTOM" .. v, 0, tileSize)
                        texture:SetWidth(tileSize)
                        texture:SetTexCoord((i - 1) * 0.125, i * 0.125, 0, 1)
                else
                        texture:SetPoint(v)
                        texture:SetSize(tileSize, tileSize)
                        texture:SetTexCoord((i - 1) * 0.125, i * 0.125, 0, 1)
                end
        end
end

Compare with Previous | Blame