Class LinearGradient
- All Implemented Interfaces:
RefCounted,Shader
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.arc3d.sketch.shaders.Gradient1DShader
Gradient1DShader.ColorTransformerNested classes/interfaces inherited from class icyllis.arc3d.sketch.shaders.GradientShader
GradientShader.Interpolation -
Field Summary
Fields inherited from class icyllis.arc3d.sketch.shaders.Gradient1DShader
mPtsToUnit, mTileModeFields inherited from class icyllis.arc3d.sketch.shaders.GradientShader
kDegenerateToleranceFields inherited from interface icyllis.arc3d.sketch.shaders.Shader
LOCAL_MATRIX_AFTER, LOCAL_MATRIX_BEFORE, LOCAL_MATRIX_REPLACE, TILE_MODE_CLAMP, TILE_MODE_DECAL, TILE_MODE_MIRROR, TILE_MODE_REPEAT -
Constructor Summary
ConstructorsConstructorDescriptionLinearGradient(float startX, float startY, float endX, float endY, float @NonNull [] colors, @Nullable ColorSpace colorSpace, float @Nullable [] positions, int colorCount, int tileMode, int interpolation) -
Method Summary
Modifier and TypeMethodDescriptionintfloatgetEndX()floatgetEndY()floatfloatstatic @Nullable @SharedPtr Shadermake(float startX, float startY, float endX, float endY, float @NonNull [] colors, @Nullable ColorSpace colorSpace, float @Nullable [] positions, int colorCount, int tileMode, int interpolation, @Nullable Matrixc localMatrix) Create a linear gradient shader.Methods inherited from class icyllis.arc3d.sketch.shaders.Gradient1DShader
checkGradient1D, colorsAreOpaque, getColorCount, getColors, getColorSpace, getGradientMatrix, getInterpolation, getPos, getPositions, getTileMode, isOpaque, makeDegenerateGradient, srgb_to_hsl, srgb_to_hwbMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface icyllis.arc3d.sketch.shaders.Shader
isTriviallyCounted, makeWithLocalMatrix, ref, unref
-
Constructor Details
-
LinearGradient
@VisibleForTesting public LinearGradient(float startX, float startY, float endX, float endY, float @NonNull [] colors, @Nullable ColorSpace colorSpace, float @Nullable [] positions, int colorCount, int tileMode, int interpolation)
-
-
Method Details
-
make
@CheckReturnValue @SharedPtr public static @Nullable @SharedPtr Shader make(float startX, float startY, float endX, float endY, float @NonNull [] colors, @Nullable ColorSpace colorSpace, float @Nullable [] positions, int colorCount, int tileMode, int interpolation, @Nullable Matrixc localMatrix) Create a linear gradient shader.The colors array holds repeated R,G,B,A values of source colors to interpolate, they are un-premultiplied and 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.
Only the first colorCount entries in array will be taken, then
colors.length >= colorCount * 4 invalid input: '&'invalid input: '&' positions.length >= colorCount.The tileMode specifies the behavior when local coords are out of bounds.
The interpolation specifies the color interpolation method, see
GradientShader.Interpolation.The localMatrix specifies an additional local matrix for this gradient, null means identity.
All given arguments will be simplified and copied into the return shader. Null is returned if there are any illegal arguments (NaN, Inf, non-invertible matrix, etc.).
- Parameters:
startX- x of start pointstartY- y of start pointendX- x of end pointendY- y of end pointcolors- color arraycolorSpace- color space, null will use the default one (sRGB)positions- position arraycolorCount- number of stopstileMode- tile modeinterpolation- interpolation methodlocalMatrix- local matrix- Returns:
- a gradient shader, or degenerate shader, or null
-
asGradient
public int asGradient() -
getStartX
public float getStartX() -
getStartY
public float getStartY() -
getEndX
public float getEndX() -
getEndY
public float getEndY()
-