feat: add color picker with palette component

This commit is contained in:
kalilistic 2021-04-12 09:34:42 -04:00
parent 7d2a900832
commit 01d84f0e65
3 changed files with 98 additions and 0 deletions

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Numerics;
using ImGuiNET;
@ -57,6 +58,23 @@ namespace Dalamud.Interface
string name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
=> ImGui.SetWindowPos(position + MainViewport.Pos, condition);
/// <summary>
/// Creates default color palette for use with color pickers.
/// </summary>
/// <param name="swatchCount">The total number of swatches to use.</param>
/// <returns>Default color palette.</returns>
public static List<Vector4> DefaultColorPalette(int swatchCount = 32)
{
var colorPalette = new List<Vector4>();
for (var i = 0; i < swatchCount; i++)
{
ImGui.ColorConvertHSVtoRGB(i / 31.0f, 0.7f, 0.8f, out var r, out var g, out var b);
colorPalette.Add(new Vector4(r, g, b, 1.0f));
}
return colorPalette;
}
/// <summary>
/// Get data needed for each new frame.
/// </summary>