Difference between revisions of "ImGui.DrawList:addLine"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui.DrawList<br/> === Description === Adds a line to an ImGui draw list. <source lang="lua"> ImGui.Dra...") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Adds a line to an ImGui draw list. | Adds a line to an ImGui draw list. | ||
− | < | + | <syntaxhighlight lang="lua"> |
ImGui.DrawList:addLine(p1, p2, color, [alpha=1, thickness=1]) | ImGui.DrawList:addLine(p1, p2, color, [alpha=1, thickness=1]) | ||
− | </ | + | </syntaxhighlight> |
=== Parameters === | === Parameters === | ||
Line 17: | Line 17: | ||
=== Example === | === Example === | ||
− | < | + | <syntaxhighlight lang="lua"> |
require "ImGui" | require "ImGui" | ||
Line 49: | Line 49: | ||
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) | stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) | ||
− | </ | + | </syntaxhighlight> |
{{ImGui.DrawList}} | {{ImGui.DrawList}} |
Latest revision as of 15:29, 13 July 2023
Available since: Gideros 2020.9
Class: ImGui.DrawList
Description
Adds a line to an ImGui draw list.
ImGui.DrawList:addLine(p1, p2, color, [alpha=1, thickness=1])
Parameters
p1: (number) the x and y coordinate of the line starting position
p2: (number) the x and y coordinate of the line ending position
color: (number) the color in hexadecimal value
alpha: (number) the alpha value
thickness: (number) the line thickness value
Example
require "ImGui"
local imgui = ImGui.new()
stage:addChild(imgui)
local window01 = true
function onEnterFrame(e)
-- 1 we start ImGui
imgui:newFrame(e)
-- 2 the main window
if window01 then -- if window exists
local windowdrawn = false
window01, windowdrawn = imgui:beginWindow(
"Hello Dear ImGui", -- window title
window01 -- is window expanded
)
if (windowdrawn) then -- the variable is false when main window is collapsed
imgui:text("Hello X Dear ImGui!") -- we add some element to our GUI
imgui:textColored("Hello, Y Dear ImGui!", 0xff00ff, 1) -- we add some element to our GUI
local drawlist = imgui:getWindowDrawList()
drawlist:addLine(32, 32, 256, 256, 0x00ff00, 1, 16)
end
imgui:endWindow()
end
-- 3 we end the frame and render to screen
imgui:endFrame()
imgui:render()
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)