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

Simplify color parsing and allow more decimals #6164

Merged
merged 2 commits into from
Nov 29, 2016
Merged

Simplify color parsing and allow more decimals #6164

merged 2 commits into from
Nov 29, 2016

Conversation

marcjansen
Copy link
Member

An alternative for #6151.

Please review.

/cc @tschaub @tchandelle

@marcjansen
Copy link
Member Author

@openlayers/ol3 : any opinions on this PR or #6151? TIA for any review.

Copy link
Member

@ahocevar ahocevar left a 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()
Copy link
Member

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()
Copy link
Member

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)

@ahocevar
Copy link
Member

This is much nicer than #6151.

@marcjansen
Copy link
Member Author

Thanks for the review, @ahocevar, I have added 88cfdb4 that remove the two regular expression in favor of indexOf checks.

I will merge once green.

@marcjansen marcjansen merged commit 4dc828c into openlayers:master Nov 29, 2016
@marcjansen marcjansen deleted the color-parsing branch November 29, 2016 10:03
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.

2 participants