Package icyllis.arc3d.sketch.shaders
Class Gradient1DShader
java.lang.Object
icyllis.arc3d.sketch.shaders.GradientShader
icyllis.arc3d.sketch.shaders.Gradient1DShader
- All Implemented Interfaces:
RefCounted
,Shader
- Direct Known Subclasses:
AngularGradient
,LinearGradient
,RadialGradient
public abstract sealed class Gradient1DShader
extends GradientShader
permits LinearGradient, RadialGradient, AngularGradient
Base class for gradient colors that can be represented by a 1D function,
it generates one parameter for interpolation:
grad_layout(x,y) -> floatSuch as linear gradient, radial gradient, angular gradient.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class icyllis.arc3d.sketch.shaders.GradientShader
GradientShader.Interpolation
-
Field Summary
FieldsFields inherited from class icyllis.arc3d.sketch.shaders.GradientShader
kDegenerateTolerance
Fields 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
ConstructorsModifierConstructorDescriptionprotected
Gradient1DShader
(float @NonNull [] inColors, @Nullable ColorSpace colorSpace, float @Nullable [] inPositions, int inColorCount, int tileMode, int interpolation, @NonNull Matrix ptsToUnit) -
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
checkGradient1D
(float[] colors, float[] positions, int colorCount, int tileMode) boolean
int
float[]
@NonNull ColorSpace
@NonNull Matrixc
int
float
getPos
(int i) float[]
int
boolean
isOpaque()
Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value.protected static @Nullable @SharedPtr Shader
makeDegenerateGradient
(float[] colors, @Nullable ColorSpace colorSpace, float[] positions, int colorCount, int tileMode) static void
srgb_to_hsl
(int i, float[] colors, BitSet hueIsPowerless) static void
srgb_to_hwb
(int i, float[] colors, BitSet hueIsPowerless) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface icyllis.arc3d.sketch.shaders.Shader
isTriviallyCounted, makeWithLocalMatrix, ref, unref
-
Field Details
-
mPtsToUnit
-
mTileMode
protected final int mTileMode
-
-
Constructor Details
-
Gradient1DShader
protected Gradient1DShader(float @NonNull [] inColors, @Nullable ColorSpace colorSpace, float @Nullable [] inPositions, int inColorCount, int tileMode, int interpolation, @NonNull Matrix ptsToUnit)
-
-
Method Details
-
isOpaque
public boolean isOpaque()Description copied from interface:Shader
Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value. Subclasses should override this to allow some optimizations. -
getColors
@VisibleForTesting public float[] getColors() -
getPositions
@VisibleForTesting public float[] getPositions() -
getPos
public float getPos(int i) -
getColorSpace
-
getColorCount
public int getColorCount() -
getInterpolation
public int getInterpolation() -
getTileMode
public int getTileMode() -
getGradientMatrix
-
colorsAreOpaque
public boolean colorsAreOpaque() -
checkGradient1D
protected static boolean checkGradient1D(float[] colors, float[] positions, int colorCount, int tileMode) -
makeDegenerateGradient
@SharedPtr protected static @Nullable @SharedPtr Shader makeDegenerateGradient(float[] colors, @Nullable ColorSpace colorSpace, float[] positions, int colorCount, int tileMode) -
srgb_to_hsl
-
srgb_to_hwb
-