View Single Post
04-26-13, 04:09 AM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Code:
function TextureBasics_CreateTexture(texture)
	-- Create a frame
	local f = CreateFrame("frame", "TextureBasics")
	-- Frame Strata ("Background", "Low", "Medium", "High", "Dialog", "Fullscreen", "Fullscreen_Dialog", "Tooltip")
	f:SetFrameStrata("Medium")
	-- Frame Strata level (0 - 20)
	f:SetFrameLevel(0)
	-- Frame Width
	f:SetWidth(128)
	-- Frame Height
	f:SetHeight(128)
	-- Frame Alpha
	f:SetAlpha(0.90)
	-- Frame Position
	f:SetPoint("CENTER", 0, 0);
	-- Create a texture on the frame
	local t = f:CreateTexture("Texture", "Background")
	-- Set the texture
	t:SetTexture(texture)
	-- Texture Width
	t:SetWidth(128)
	-- Texture Height
	t:SetHeight(128)
	-- Blend Mode ("Add", "Alphakey", "Blend", "Disable", "Mod")
	t:SetBlendMode("Disable")
	-- Texture Strata ("Background", "Border", "Artwork", "Overlay") and Sublevel (-8 - 7)
	t:SetDrawLayer("Background", 0)
	-- Texture Rotation (0 - 360) (Note, not all textures like to be rotated)
	t:SetRotation(math.rad(15))
	-- Coloring (r, b, g, a)
	t:SetVertexColor(1, 0, 0, 0.75)
	-- If you rotate it you need multiply the frame's width and height by sqrt(2)
	f:SetWidth(sqrt(2) * t:GetWidth())
	f:SetHeight(sqrt(2) * t:GetHeight())
	-- Mirror it
	local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = t:GetTexCoord();
	--t:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy); -- Inverse X
	--t:SetTexCoord(LLx, LLy, ULx, ULy, LRx, LRy, URx, URy); -- Inverse Y
	--t:SetTexCoord(LRx, LRy, URx, URy, LLx, LLy, ULx, ULy); -- Inverse XY
	t:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy); -- Normal
	-- Put the texture on the frame
	t:SetAllPoints(f)
	-- Show it
	f:Show()
end

TextureBasics_CreateTexture("Interface\\PVPFrame\\Icons\\PVP-Banner-Emblem-10")
You can draw more texture ingame with command:

Code:
/run TextureBasics_CreateTexture(texture)
If you rotate icons from the game you gonna get a glitch:

Code:
/run TextureBasics_CreateTexture("Interface\\Icons\\Ability_Ambush")
https://github.com/Resike/TextureBasics

Last edited by Resike : 04-26-13 at 04:33 AM.
  Reply With Quote