-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Simplify color parsing and allow more decimals #6164
Conversation
@openlayers/ol3 : any opinions on this PR or #6151? TIA for any review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but you can get rid of two more regular expressions. Please merge when done.
g = Number(match[2]); | ||
b = Number(match[3]); | ||
color = ol.color.normalize([r, g, b, 1]); | ||
} else if (ol.color.RGBA_COLOR_RE_.test(s)) { // rgba() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (s.indexOf('rgba(') == 0) {
} else if (ol.color.RGBA_COLOR_RE_.test(s)) { // rgba() | ||
parts = s.slice(5, -1).split(',').map(Number); | ||
color = ol.color.normalize(parts); | ||
} else if (ol.color.RGB_COLOR_RE_.test(s)) { // rgb() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (s.indexOf('rgb(') == 0)
This is much nicer than #6151. |
An alternative for #6151.
Please review.
/cc @tschaub @tchandelle