Skip to content

Instantly share code, notes, and snippets.

@av
Created September 29, 2019 10:21
Show Gist options
  • Save av/f04e05a0ee3fecb649431bc9490a71bd to your computer and use it in GitHub Desktop.
Save av/f04e05a0ee3fecb649431bc9490a71bd to your computer and use it in GitHub Desktop.
Flutter: x-axis gradient
/// 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