Skip to content

Commit

Permalink
Add color tinting to images
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-edmondson committed Aug 28, 2024
1 parent b225dc6 commit 05a97c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions ImGuiWidgets/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ namespace ktsu.io.ImGuiWidgets;

public static class Image
{
public static bool Show(uint textureId, Vector2 size)
public static bool Show(uint textureId, Vector2 size) => Show(textureId, size, Vector4.One);
public static bool Show(uint textureId, Vector2 size, Vector4 color)
{
ImGui.Image((nint)textureId, size);
ImGui.Image((nint)textureId, size, Vector2.Zero, Vector2.One, color);
return ImGui.IsItemClicked();
}

public static bool Centered(uint textureId, Vector2 size)
public static bool Centered(uint textureId, Vector2 size) => Centered(textureId, size, Vector4.One);
public static bool Centered(uint textureId, Vector2 size, Vector4 color)
{
Alignment.Center(size.X);
return Show(textureId, size);
return Show(textureId, size, color);
}

public static bool CenteredWithin(uint textureId, Vector2 size, float width)
public static bool CenteredWithin(uint textureId, Vector2 size, float width) => CenteredWithin(textureId, size, width, Vector4.One);
public static bool CenteredWithin(uint textureId, Vector2 size, float width, Vector4 color)
{
if (width < size.X)
{
Expand All @@ -26,6 +29,6 @@ public static bool CenteredWithin(uint textureId, Vector2 size, float width)
}

Alignment.CenterWithin(size.X, width);
return Show(textureId, size);
return Show(textureId, size, color);
}
}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-alpha.33
1.0.0-alpha.34

0 comments on commit 05a97c2

Please sign in to comment.