Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added alpha to FromColorString and ColorHexString #119

Closed

Conversation

imtrobin
Copy link

@imtrobin imtrobin commented Jun 1, 2020

Fixes #118

Comment on lines +85 to +87
public static string FromDrawingColor(System.Drawing.Color color, byte alpha = 0)
{
return ColorHexString(color.R, color.G, color.B);
return ColorString(color.R, color.G, color.B, (double)color.A / byte.MaxValue);
Copy link
Contributor

@Joelius300 Joelius300 Jun 1, 2020

Choose a reason for hiding this comment

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

You should probably remove the unused alpha parameter, right?

Also the summary still says "as hex" but you're using ColorString instead of ColorHexString now. You should use the newly added ColorHexString. We could also consider removing the "as hex" part in the summary and keep using ColorString but my personal preference is using ColorHexString.

/// <returns></returns>
public static string ColorHexString(byte r, byte g, byte b, double alpha)
{
return $"#{r:X2}{g:X2}{b:X2}{(byte)(alpha * 255):X2}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Use byte.MaxValue instead of 255.

@Joelius300
Copy link
Contributor

Coming back to the repo to do some cleaning. Have you had time to look at my review?

@Joelius300
Copy link
Contributor

This PR was made redundant by ea4b914. Thank you for your contribution anyway :)

@Joelius300 Joelius300 closed this Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FromDrawingColor Alpha
2 participants