Add ColorExtensions for System.Drawing.Color#67
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/63800f13-cdf0-436c-8929-16b9ab375475 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
| /// <summary> | ||
| /// Returns the hexadecimal representation of the color (e.g., <c>#RRGGBB</c>). | ||
| /// </summary> | ||
| public string ToHex() => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; |
There was a problem hiding this comment.
| public string ToHex() => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; | |
| public string ToHexString() => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; |
There was a problem hiding this comment.
Done — renamed to ToHexString() in commit 2412ff7.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #67 +/- ##
==========================================
- Coverage 94.85% 94.02% -0.83%
==========================================
Files 120 126 +6
Lines 2333 2478 +145
Branches 177 197 +20
==========================================
+ Hits 2213 2330 +117
- Misses 86 107 +21
- Partials 34 41 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/c0c8f175-a590-4485-8b43-0a47b87b465f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/3d5a0792-5e1c-456a-88fe-617f5af504b8 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds System.Drawing.Color extension members to PowerKit, providing small convenience helpers for common color representations and alpha manipulation.
Changes:
- Introduces
ColorExtensionswithToHex(),ToRgb(),WithAlpha(int), andResetAlpha(). - Adds unit tests covering the new color extension behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| PowerKit/Extensions/ColorExtensions.cs | Adds new instance extension members on System.Drawing.Color for hex/RGB conversion and alpha manipulation. |
| PowerKit.Tests/Extensions/ColorExtensionsTests.cs | Adds test coverage for ToHex, ToRgb, WithAlpha, and ResetAlpha. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ports the
Colorextensions from DiscordChatExporter into PowerKit as instance extension methods onSystem.Drawing.Color.New extensions
ToHexString()→"#RRGGBB"hex stringToRgb()→ RGB value asint(alpha stripped)WithAlpha(int alpha)→ newColorwith the given alpha