Last active
September 29, 2019 10:37
-
-
Save av/7816d20b1f30f304c6643518e7b222c6 to your computer and use it in GitHub Desktop.
Flutter: vector3 to rgba int color
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
/// Takes a unit Vector3 (all values from 0 to 1) | |
/// and returns an int representing color in RGBA format | |
/// Vector3(0, 1, 0) -> 0xff00ff00 | |
int toColorInt(Vector3 vec) { | |
int r = (vec.r * 255).toInt(); | |
int g = (vec.g * 255).toInt(); | |
int b = (vec.b * 255).toInt(); | |
return (b << 0) | (g << 8) | (r << 16) | (255 << 32); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment