ImGui.DrawList:addRect

From GiderosMobile

Available since: Gideros 2020.9
Class: ImGui.DrawList

Description

Adds a rectangle to an ImGui draw list.

ImGui.DrawList:addRect(p_min_x, p_min_y, p_max_x, p_max_y, color,
  [rounding=0, rounding_corners=ImGui.CornerFlags_All, thickness=1])

Parameters

p_min_x: (number) the rectangle minimum x coordinate
p_min_y: (number) the rectangle minimum y coordinate
p_max_x: (number) the rectangle maximum x coordinate
p_max_y: (number) the rectangle maximum y coordinate
color: (number) the color in hexadecimal format
alpha: (number) the alpha value between 0 and 1
rounding: (number) the corners rounding value
rounding_corners: (string) one of ImGui.CONST.CornerFlags
thickness: (number) the rectangle 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 Dear ImGui!") -- we add some element to our GUI
			local drawlist = imgui:getWindowDrawList()
			drawlist:addCircle(128, 128, 64, 0x00ff00, 1, 32)
			drawlist:addRect(128, 128, 196, 196, 0x00ffff, 1, 16, ImGui.CornerFlags_Bot, 3)
		end
		imgui:endWindow()
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)