Skip to content

Add ColorExtensions for System.Drawing.Color#67

Merged
Tyrrrz merged 3 commits intoprimefrom
copilot/add-color-extensions
Apr 19, 2026
Merged

Add ColorExtensions for System.Drawing.Color#67
Tyrrrz merged 3 commits intoprimefrom
copilot/add-color-extensions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

Ports the Color extensions from DiscordChatExporter into PowerKit as instance extension methods on System.Drawing.Color.

New extensions

  • ToHexString()"#RRGGBB" hex string
  • ToRgb() → RGB value as int (alpha stripped)
  • WithAlpha(int alpha) → new Color with the given alpha
var color = Color.FromArgb(128, 0xFF, 0x36, 0x00);

color.ToHexString()   // "#FF3600"
color.ToRgb()         // 0xFF3600
color.WithAlpha(64)   // Color with A=64, same RGB

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/63800f13-cdf0-436c-8929-16b9ab375475

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread PowerKit/Extensions/ColorExtensions.cs Outdated
Comment thread PowerKit/Extensions/ColorExtensions.cs Outdated
/// <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}";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public string ToHex() => $"#{color.R:X2}{color.G:X2}{color.B:X2}";
public string ToHexString() => $"#{color.R:X2}{color.G:X2}{color.B:X2}";

@copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — renamed to ToHexString() in commit 2412ff7.

@Tyrrrz Tyrrrz marked this pull request as ready for review April 19, 2026 07:44
Copilot AI review requested due to automatic review settings April 19, 2026 07:44
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (eb22eec) to head (2412ff7).
⚠️ Report is 4 commits behind head on prime.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds System.Drawing.Color extension members to PowerKit, providing small convenience helpers for common color representations and alpha manipulation.

Changes:

  • Introduces ColorExtensions with ToHex(), ToRgb(), WithAlpha(int), and ResetAlpha().
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants