DVUI

getHueSelectorTexture

Parameters

#
dir:dvui.enums.Direction
dvui.enums.Direction

Source

Implementation

#
pub fn getHueSelectorTexture(dir: dvui.enums.Direction) dvui.Backend.TextureError!dvui.Texture {
    var h = dvui.fnv.init();
    h.update("hue");
    h.update(std.mem.asBytes(&dir));
    const id = h.final();
    if (dvui.textureGetCached(id)) |cached| return cached else {
        const width: u32, const height: u32 = switch (dir) {
            .horizontal => .{ hue_selector_colors.len, 1 },
            .vertical => .{ 1, hue_selector_colors.len },
        };
        const texture = try dvui.textureCreate(&hue_selector_colors, .{ .width = width, .height = height });
        dvui.textureAddToCache(id, texture);
        return texture;
    }
}