Frame:CreateLine

From Warcraft Wiki
Jump to navigation Jump to search

Draws a line.

line = Frame:CreateLine([name, drawLayer, templateName, subLevel])

Arguments

name
string?
drawLayer
string? : DrawLayer
templateName
string?
subLevel
number? [-8, 7] = 0 - The level of the sublayer if anything else overlaps.

Returns

line
Line🔗 - The new line object as a child of this frame.

Example

Draws a diagonal red line with a default thickness of 4.

local l = UIParent:CreateLine()
l:SetColorTexture(1, 0, 0)
l:SetStartPoint("CENTER", -20, 20) -- start topleft
l:SetEndPoint("CENTER", 20, -20)  -- end bottomright

API Frame CreateLine 01.png

Draws a triangle with differently colored lines.

local function DrawLine(r, g, b, x1, y1, x2, y2)
	local line = UIParent:CreateLine()
	line:SetColorTexture(r, g, b)
	line:SetThickness(2)
	line:SetStartPoint("CENTER", UIParent, x1, y1)
	line:SetEndPoint("CENTER", UIParent, x2, y2)
end

DrawLine(1,0,0, 0,0, 0,40)
DrawLine(0,1,0, 0,40, 40,0)
DrawLine(0,0,1, 40,0, 0,0)

API Frame CreateLine 02.png