Class LinearGradient
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.GradientShader
GradientShader.HueInterpolationMethod, GradientShader.InterpolationColorSpace
Nested classes/interfaces inherited from class icyllis.modernui.graphics.Shader
Shader.TileMode
-
Constructor Summary
ConstructorDescriptionLinearGradient
(float startX, float startY, float endX, float endY, float[] colors, ColorSpace colorSpace, float[] positions, Shader.TileMode tileMode, Matrix localMatrix) Create a linear gradient shader.LinearGradient
(float startX, float startY, float endX, float endY, int[] colors, float[] positions, Shader.TileMode tileMode, Matrix localMatrix) Simplified constructor that takes an array of 0xAARRGGBB colors in sRGB color space.LinearGradient
(float startX, float startY, float endX, float endY, int startColor, int endColor, Shader.TileMode tileMode, Matrix localMatrix) Simplified constructor that takes two 0xAARRGGBB colors in sRGB color space. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getLocalMatrix
(Matrix localMatrix) Return true if the shader has a non-identity local matrix.Methods inherited from class icyllis.modernui.graphics.GradientShader
convertColors
-
Constructor Details
-
LinearGradient
public LinearGradient(float startX, float startY, float endX, float endY, @ColorInt int startColor, @ColorInt int endColor, @NonNull Shader.TileMode tileMode, @Nullable Matrix localMatrix) Simplified constructor that takes two 0xAARRGGBB colors in sRGB color space.- See Also:
-
LinearGradient
public LinearGradient(float startX, float startY, float endX, float endY, @NonNull @ColorInt int[] colors, @Nullable float[] positions, @NonNull Shader.TileMode tileMode, @Nullable Matrix localMatrix) Simplified constructor that takes an array of 0xAARRGGBB colors in sRGB color space.- See Also:
-
LinearGradient
public LinearGradient(float startX, float startY, float endX, float endY, @Size(multiple=4L) @NonNull float[] colors, @Nullable ColorSpace colorSpace, @Nullable float[] positions, @NonNull Shader.TileMode tileMode, @Nullable Matrix localMatrix) Create a linear gradient shader.The colors array holds repeated R,G,B,A values of source colors to interpolate, they have non-premultiplied alpha and are in the given colorSpace.
The positions array specifies a number of stops, all values are between 0 and 1 and monotonic increasing. Colors will be linearly interpolated in each stop. Null means that they are uniformly distributed. If the first position is not 0 or the last position is not 1, an implicit stop will be added.
The tileMode specifies the behavior when local coords are out of bounds.
The localMatrix specifies an additional local matrix for this gradient, it transforms gradient's local coordinates to geometry's local coordinates, null means identity.
All given arguments will be simplified and copied into the internal shader.
- Parameters:
startX
- x-coordinate for the start pointstartY
- y-coordinate for the start pointendX
- x-coordinate for the end pointendY
- y-coordinate for the end pointcolors
- color arraycolorSpace
- color space, null will use the default one (sRGB)positions
- position arraytileMode
- tile modelocalMatrix
- local matrix- Throws:
IllegalArgumentException
- NaN, infinity, non-invertible matrix, etc.
-
-
Method Details
-
getLocalMatrix
Return true if the shader has a non-identity local matrix.- Parameters:
localMatrix
- Set to the local matrix of the shader, if the shader's matrix is non-null.- Returns:
- true if the shader has a non-identity local matrix
-