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

Allow colors to include an alpha value. #636

Merged
merged 2 commits into from
Oct 27, 2016
Merged

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Oct 25, 2016

Also, handle more css color specifications. Currently, nothing takes advantage of a color which has an alpha value (though the pixelmap soon will). It would be nice to be able to use that in addition to opacity styles.

Before, we handled colors of the form rgb object, #rrggbb, #rgb, and css color names. This adds parsing of #rrggbbaa, #rgba, rgb(), rgba(), hsl(), hsla(), and 'transparent', conforming that parsing to the css working group's current draft standard (there are other color formats in that draft that are not implemented). It also adds one additional css color name, as per that draft.

Also, handle more css color specifications.  Currently, nothing takes advantage of a color which has an alpha value (though the pixelmap soon will).  It would be nice to be able to use that in addition to opacity styles.

Before, we handled colors of the form rgb object, #rrggbb, #rgb, and css color names.  This adds parsing of #rrggbbaa, #rgba, rgb(), rgba(), hsl(), hsla(), and 'transparent', conforming that parsing to the css working group's current draft standard (there are other color formats in that draft that are not implemented).  It also adds one additional css color name, as per that draft.
@codecov-io
Copy link

codecov-io commented Oct 25, 2016

Current coverage is 86.52% (diff: 100%)

Merging #636 into master will increase coverage by 0.05%

@@             master       #636   diff @@
==========================================
  Files            85         85          
  Lines          8290       8325    +35   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           7168       7203    +35   
  Misses         1122       1122          
  Partials          0          0          

Powered by Codecov. Last update d14a319...a11d827

@manthey manthey mentioned this pull request Oct 27, 2016
Copy link
Member

@aashish24 aashish24 left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me, I didn't review the regex in detail though.

Math.round(rgb.b * 255)).toString(16).slice(1);
}
if (rgb.a !== undefined && allowAlpha) {
value += (256 + Math.round(rgb.a * 255)).toString(16).slice(1);
Copy link
Member

Choose a reason for hiding this comment

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

clever

@manthey manthey merged commit cf6aeb5 into master Oct 27, 2016
@manthey manthey deleted the colors-with-opacity branch October 27, 2016 15:26
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.

3 participants