Package icyllis.arc3d.sketch.shaders
Class ColorShader
java.lang.Object
icyllis.arc3d.sketch.shaders.ColorShader
- All Implemented Interfaces:
RefCounted
,Shader
A Shader that represents a single color. In general, this effect can be accomplished by just
using the color field on the paint, but if an actual shader object is needed, this provides that
feature. Note: like all shaders, at draw time the paint's alpha will be respected, and is
applied to the specified color.
-
Field Summary
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
ConstructorsConstructorDescriptionColorShader
(float r, float g, float b, float a) Create a ColorShader wrapping the given sRGB color.ColorShader
(int color) Create a ColorShader wrapping the given sRGB color. -
Method Summary
Modifier and TypeMethodDescriptionfloat @NonNull []
getColor()
boolean
Returns true if the shader is guaranteed to produce only a single color.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.static @SharedPtr @Nullable Shader
make
(float @NonNull [] color, @Nullable ColorSpace space) static @SharedPtr @Nullable Shader
make
(float r, float g, float b, float a, @Nullable ColorSpace space) 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
-
Constructor Details
-
ColorShader
public ColorShader(int color) Create a ColorShader wrapping the given sRGB color. -
ColorShader
@VisibleForTesting public ColorShader(float r, float g, float b, float a) Create a ColorShader wrapping the given sRGB color.
-
-
Method Details
-
make
@Contract(pure=true) @SharedPtr public static @SharedPtr @Nullable Shader make(@Size(4L) float @NonNull [] color, @Nullable ColorSpace space) -
make
@Contract(pure=true) @SharedPtr public static @SharedPtr @Nullable Shader make(float r, float g, float b, float a, @Nullable ColorSpace space) -
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. -
isConstant
public boolean isConstant()Returns true if the shader is guaranteed to produce only a single color. Subclasses can override this to allow loop-hoisting optimization.- Specified by:
isConstant
in interfaceShader
-
getColor
@Contract(value=" -> new", pure=true) public float @NonNull [] getColor()- Returns:
- a copy of non-premultiplied color.
-