Class: ImColor

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/imgui.rb

Overview

Helper: ImColor() implicitly converts colors to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float) Prefer using IM_COL32() macros if you want a guaranteed compile-time ImU32 for usage with ImDrawList API. **Avoid storing ImColor! Store either u32 of ImVec4. This is not a full-featured color class. MAY OBSOLETE. **None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either ImU32 or ImVec4 formats. Explicitly cast to ImU32 or ImVec4 if needed.

Class Method Summary collapse

Class Method Details

.col32(r = 0, g = 0, b = 0, a = 255) ⇒ Object



2708
2709
2710
# File 'lib/imgui.rb', line 2708

def ImColor.col32(r = 0, g = 0, b = 0, a = 255)
  return ((a.to_i << 24) | (b.to_i << 0) | (g.to_i << 8) | (r.to_i << 16))
end

.create(r = 0, g = 0, b = 0, a = 255) ⇒ Object



2698
2699
2700
2701
2702
2703
2704
2705
2706
# File 'lib/imgui.rb', line 2698

def ImColor.create(r = 0, g = 0, b = 0, a = 255)
  sc = 1.0 / 255.0
  instance = ImColor.new
  instance[:Value][:x] = r.to_f * sc
  instance[:Value][:y] = g.to_f * sc
  instance[:Value][:z] = b.to_f * sc
  instance[:Value][:w] = a.to_f * sc
  return instance
end