Created
September 29, 2019 10:21
-
-
Save av/f04e05a0ee3fecb649431bc9490a71bd to your computer and use it in GitHub Desktop.
Flutter: x-axis gradient
This file contains 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
/// Main area of interest, this function will | |
/// return color for each particular color on our [ui.Image] | |
int generatePixel(int x, int y, Size size) { | |
/// Compute unified vector, values of its components | |
/// will be between 0 and 1 | |
var uv = Vector2(x / size.width, y / size.height); | |
/// [Vector2.xxx] is a getter which returns [Vector3] | |
/// with first component of given [Vector2], uv in our case. | |
return toColorInt(uv.xxx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment