Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions PowerKit.Tests/Extensions/ColorExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ public void WithAlpha_Test()
Color.FromArgb(255, 0x12, 0x34, 0x56).WithAlpha(128).B.Should().Be(0x56);
Color.FromArgb(0, 0xff, 0xff, 0xff).WithAlpha(255).A.Should().Be(255);
}

[Fact]
public void WithFullAlpha_Test()
{
// Act & assert
Color.FromArgb(0, 0x12, 0x34, 0x56).WithFullAlpha().A.Should().Be(255);
Color.FromArgb(0, 0x12, 0x34, 0x56).WithFullAlpha().R.Should().Be(0x12);
Color.FromArgb(0, 0x12, 0x34, 0x56).WithFullAlpha().G.Should().Be(0x34);
Color.FromArgb(0, 0x12, 0x34, 0x56).WithFullAlpha().B.Should().Be(0x56);
Comment thread
Tyrrrz marked this conversation as resolved.
}
}
5 changes: 5 additions & 0 deletions PowerKit/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ internal static class ColorExtensions
/// Returns a new <see cref="Color" /> with the specified alpha value.
/// </summary>
public Color WithAlpha(int alpha) => Color.FromArgb(alpha, color);

/// <summary>
/// Returns a new <see cref="Color" /> with a full alpha channel.
Comment thread
Tyrrrz marked this conversation as resolved.
Outdated
/// </summary>
public Color WithFullAlpha() => color.WithAlpha(255);
}
}