Class RasterGradient
java.lang.Object
com.codename1.backend.image.RasterGradient
- All Implemented Interfaces:
RasterPaint
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").
-
Method Summary
Modifier and TypeMethodDescriptionintgetColor(double x, double y) Returns the gradient's color at a point.static RasterGradientlinear(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).static RasterGradientradial(double cx, double cy, double radius, float[] fractions, int[] colors) Creates a circular gradient from the center (fraction 0) to the circle ofradius(fraction 1).
-
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
x1: start xy1: start yx2: end xy2: end yfractions: stop positions, 0 to 1, not decreasingcolors: 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
cx: center xcy: center yradius: radius, above zerofractions: stop positions, 0 to 1, not decreasingcolors: 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
x: user-space xy: user-space y
Returns
the ARGB color
- Specified by:
getColorin interfaceRasterPaint
-