This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Emulate toHex function of core art Color#44
Closed
danielwinkler wants to merge 0 commit intoreact-native-art:masterfrom
danielwinkler:master
Closed
Emulate toHex function of core art Color#44danielwinkler wants to merge 0 commit intoreact-native-art:masterfrom danielwinkler:master
danielwinkler wants to merge 0 commit intoreact-native-art:masterfrom
danielwinkler:master
Conversation
Author
|
I added further code, as Android is using AARRGGBB hex vs iOS RRGGBBAA |
Esemesek
reviewed
Dec 18, 2019
lib/helpers.js
Outdated
Comment on lines
82
to
93
| const intValues = [c.red, c.green, c.blue]; | ||
| if (c.alpha < 1) { | ||
| // Android uses AARRGGBB ; iOS uses RRGGBBAA | ||
| // https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) | ||
| const position = Platform.OS === 'android' ? 0 : 3; | ||
| intValues.splice(position, 0, Math.round(c.alpha * 255)); | ||
| } | ||
| const hexValues = intValues.map(iv => { | ||
| const sv = iv.toString(16); | ||
| return sv.length === 1 ? '0' + sv : sv; | ||
| }); | ||
| return '#' + hexValues.join(''); |
Collaborator
There was a problem hiding this comment.
Can you extract this thing to a separate function called toHex?
Collaborator
|
It seems like I managed to mess up things by mistake. Didn't mean to push with force here. I will create another PR with those changes. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Color.toHex.Test Plan
What's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.mdCHANGELOG.mdexample/App.js)