Skip to content

Conversation

@JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Feb 2, 2020

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

  • Adds Color.TryParse
  • Adds Color.Parse
  • Adds Color.TryParseHex
  • Renames Color.FromHex to Color.ParseHex
  • Adds Rgba32.TryParseHex
  • Renames Rgba32.FromHex to Rgba32.ParseHex

Color.TryParse and Color.Parse recognize both color names and hexadecimal representation as per CSS4 specification in ordinal casing. Fix #1103

I haven't added Rgba32.TryParse and Rgba32.Parse as I'm very tempted to drop the Rgba32 named colors. I'd much rather channel color creation through the Color struct only.

Please let me know if you agree that this is the best course of action.

EDIT. I went ahead and deleted them. Much happier now.

@codecov
Copy link

codecov bot commented Feb 2, 2020

Codecov Report

Merging #1104 into master will increase coverage by 0.69%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1104      +/-   ##
==========================================
+ Coverage   81.53%   82.22%   +0.69%     
==========================================
  Files         704      702       -2     
  Lines       29384    29159     -225     
  Branches     3290     3296       +6     
==========================================
+ Hits        23957    23977      +20     
+ Misses       4734     4491     -243     
+ Partials      693      691       -2
Flag Coverage Δ
#unittests 82.22% <100%> (+0.69%) ⬆️
Impacted Files Coverage Δ
...rp/PixelFormats/PixelImplementations/RgbaVector.cs 93.18% <100%> (ø) ⬆️
src/ImageSharp/Color/Color.WernerPalette.cs 100% <100%> (ø) ⬆️
src/ImageSharp/Color/Color.NamedColors.cs 100% <100%> (ø) ⬆️
...eSharp/PixelFormats/PixelImplementations/Rgba32.cs 97.93% <100%> (+3%) ⬆️
src/ImageSharp/Color/Color.cs 95.74% <100%> (+1.99%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cf2e46...386ba93. Read the comment docs.

@JimBobSquarePants
Copy link
Member Author

@SixLabors/core Any objections to this. I'll add it tonight otherwise.

@brianpopow
Copy link
Collaborator

@SixLabors/core Any objections to this. I'll add it tonight otherwise.

i have looked trough the changes. Looks good to me, i think it can be merged.

@JimBobSquarePants JimBobSquarePants merged commit ff371db into master Feb 4, 2020
@JimBobSquarePants JimBobSquarePants deleted the js/feature-color-parse branch February 4, 2020 11:46
@jespersh
Copy link

Is this the commit that broke examples that use like?:

image.Mutate(x => x.BackgroundColor(Rgba32.White));

I suppose the replacement is just using Color.White instead?

@JimBobSquarePants
Copy link
Member Author

There’s nothing broken, this is by design. Color is the correct pixel agnostic way to declare colors.

@jespersh
Copy link

I didn't say it was broken, I said it broke the examples 😄

@JimBobSquarePants
Copy link
Member Author

Which examples are broken? I’ll update if we own them.

@jespersh
Copy link

I followed this path to here:
https://stackoverflow.com/a/60642706
#355 (comment)

Thanks for this library.

@JimBobSquarePants
Copy link
Member Author

@jespersh no worries! yeah, that's all out of date. We've got API docs https://docs.sixlabors.com/ that will be much more useful.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Color.FromHtml

4 participants