Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class RasterGradient
- Object
- RasterGradient
ImplementsRasterPaint
A linear or radial color gradient for RasterGraphics.setPaint(RasterPaint).
Colors are interpolated per channel, not premultiplied, between stops at increasing fractions from 0 to 1. Before the first stop and after the last one the end colors extend (“pad”).
Methods
public static RasterGradient linear(double x1, double y1, double x2, double y2, float[] fractions, int[] colors) | Creates a gradient along the line from (x1, y1) (fraction 0) to (x2, y2) (fraction 1). |
public static RasterGradient radial(double cx, double cy, double radius, float[] fractions, int[] colors) | Creates a circular gradient from the center (fraction 0) to the circle of radius (fraction 1). |
public int getColor(double x, double y) | Returns the gradient’s color at a point. |
Inherited methods
Method details
linear
public static RasterGradient linear(double x1, double y1, double x2, double y2, float[] fractions, int[] colors)Creates a gradient along the line from
(x1, y1) (fraction 0) to
(x2, y2) (fraction 1).Parameters
x1double- start x
y1double- start y
x2double- end x
y2double- end y
fractionsfloat[]- stop positions, 0 to 1, not decreasing
colorsint[]- ARGB color of each stop
Returns
the gradient
radial
public static RasterGradient radial(double cx, double cy, double radius, float[] fractions, int[] colors)Creates a circular gradient from the center (fraction 0) to the
circle of
radius (fraction 1).Parameters
cxdouble- center x
cydouble- center y
radiusdouble- radius, above zero
fractionsfloat[]- stop positions, 0 to 1, not decreasing
colorsint[]- ARGB color of each stop
Returns
the gradient
getColor
public int getColor(double x, double y)Returns the gradient’s color at a point.
Parameters
xdouble- user-space x
ydouble- user-space y
Returns
the ARGB color