ImGui.Core:colorPicker4

From GiderosMobile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Available since: Gideros 2020.9
Class: ImGui

Description

Displays an RGBA color picker widget.

(number), (number), (number), (number), (bool) = ImGui:colorPicker4(label, color, alpha,
  [ImGuiColorEditFlags=0, originalColor=0xffffff, originalAlpha=1])

Parameters

label: (string) the label
color: (number) the current color
alpha: (number) the current alpha
ImGuiColorEditFlags: (number) one of ImGui color edit flags
originalColor: (number) the current original color
originalAlpha: (number) the current original alpha

Return values

Returns (number) the current color
Returns (number) the current alpha
Returns (number) the current original color
Returns (number) the current original alpha
Returns (bool) whether the current color has changed

Example

require "ImGui"

local imgui = ImGui.new()
stage:addChild(imgui)

local window01 = true
local hexcolor = 0x00ff00
local alpha = 0.5
local originalcolor = 0xff0000
local originalalpha = 1.0

function onEnterFrame(e)
	-- 1 we start ImGui
	imgui:newFrame(e.deltaTime)
	-- 2 we add some child windows and build our GUI
	window01 = imgui:beginWindow("Window 01") -- no close button (X)
	if window01 then -- the variable is false when window is collapsed
		imgui:text("Hello Dear ImGui!")
		local isChanged = false
		hexcolor, alpha, originalcolor, originalalpha, isChanged = imgui:colorPicker4("label", hexcolor, alpha, 0, originalcolor, originalalpha)
		if isChanged then print(hexcolor, alpha, originalcolor, originalalpha) end
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)