Difference between revisions of "ImGui.Core:colorEdit4"

From GiderosMobile
(.deltaTime)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Displays an RGBA color edit widget that consists of 4 inputs (RGBA) along with a color picker.
 
Displays an RGBA color edit widget that consists of 4 inputs (RGBA) along with a color picker.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number), (number), (bool) = ImGui:colorEdit4(label, color, alpha, [ImGuiColorEditFlags=0])
 
(number), (number), (bool) = ImGui:colorEdit4(label, color, alpha, [ImGuiColorEditFlags=0])
 
</source>
 
</source>
Line 21: Line 21:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "ImGui"
 
require "ImGui"
  

Revision as of 15:27, 13 July 2023

Available since: Gideros 2020.9
Class: ImGui

Description

Displays an RGBA color edit widget that consists of 4 inputs (RGBA) along with a color picker. <syntaxhighlight lang="lua"> (number), (number), (bool) = ImGui:colorEdit4(label, color, alpha, [ImGuiColorEditFlags=0]) </source>

Parameters

label: (string) the label
color: (number) the current color
alpha: (number) the current alpha between 0 and 1
ImGuiColorEditFlags: (number) one of ImGui color edit flags

Return values

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

Example

<syntaxhighlight lang="lua"> require "ImGui"

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

local window01 = true local hexcolor = 0x00ff00 local alpha = 0.5

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, isChanged = imgui:colorEdit4("label", hexcolor, alpha, 0) if isChanged then print(hexcolor, alpha) end end -- 3 we end the frame and render to screen imgui:endFrame() imgui:render() end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) </source>