Class LinearGradient
java.lang.Object
com.codename1.ui.Gradient
com.codename1.ui.LinearGradient
- All Implemented Interfaces:
Paint
Multi-stop linear gradient at an arbitrary angle. Mirrors CSS
linear-gradient(<angle>, <stops>). Angle is in CSS degrees: 0 points
up (toward the top edge), 90 right, 180 down, 270 left.
Since
8.1
-
Field Summary
Fields inherited from class Gradient
CYCLE_NONE, CYCLE_REFLECT, CYCLE_REPEAT, KIND_CONIC, KIND_LINEAR, KIND_RADIAL -
Constructor Summary
ConstructorsConstructorDescriptionLinearGradient(float angleDegrees, int[] colors, float[] positions) Creates a linear gradient at the given angle with the given stops. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomputeEndpoints(int width, int height, float[] out) Computes the endpoints of the gradient line for a rectangle of the given width / height (rect origin at (0,0)).copy()Returns a defensive deep copy.floatbytegetKind()Returns one ofKIND_LINEAR,KIND_RADIAL,KIND_CONIC.intsampleArgb(int px, int py, int width, int height) Software-rasterizer hook used by the default port implementation when no native gradient shader is available.setAngleDegrees(float angleDegrees) Methods inherited from class Gradient
getColors, getCycleMethod, getPositions, paint, paint, sampleStops, setCycleMethod
-
Constructor Details
-
LinearGradient
public LinearGradient(float angleDegrees, int[] colors, float[] positions) Creates a linear gradient at the given angle with the given stops.
-
-
Method Details
-
getKind
-
getAngleDegrees
public float getAngleDegrees() -
setAngleDegrees
-
computeEndpoints
public void computeEndpoints(int width, int height, float[] out) Computes the endpoints of the gradient line for a rectangle of the given width / height (rect origin at (0,0)). Output is x0,y0,x1,y1. -
sampleArgb
public int sampleArgb(int px, int py, int width, int height) Description copied from class:GradientSoftware-rasterizer hook used by the default port implementation when no native gradient shader is available. Samples an ARGB color for the pixel at (px, py) within a rectangle of the given width / height. Ports overridingfillGradientdirectly do not call this.- Specified by:
sampleArgbin classGradient
-
copy
Description copied from class:GradientReturns a defensive deep copy. Implemented by each concrete subclass so async-paint queues can capture an immutable snapshot.
-