LinearGradientpublic class LinearGradient extends Gradient
Fields Summary |
---|
int | x0 | int | y0 | int | x1 | int | y1 | long | mx | long | my | long | b |
Constructors Summary |
---|
public LinearGradient(int x0, int y0, int x1, int y1, Transform6 gradientTransform, GradientColorMap colorMap)
super(gradientTransform, colorMap);
this.x0 = x0;
this.y0 = y0;
this.x1 = x1;
this.y1 = y1;
computeTransform();
|
Methods Summary |
---|
private void | computeTransform()
float fx0 = x0/65536.0f;
float fx1 = x1/65536.0f;
float fy0 = y0/65536.0f;
float fy1 = y1/65536.0f;
float fdx = fx1 - fx0;
float fdy = fy1 - fy0;
float flensq = fdx*fdx + fdy*fdy;
float a00 = inverse.m00/65536.0f;
float a01 = inverse.m01/65536.0f;
float a02 = inverse.m02/65536.0f;
float a10 = inverse.m10/65536.0f;
float a11 = inverse.m11/65536.0f;
float a12 = inverse.m12/65536.0f;
this.mx = (int)(65536.0f*(a00*fdx + a10*fdy)/flensq);
this.my = (int)(65536.0f*(a01*fdx + a11*fdy)/flensq);
float t = fdx*fx0 + fdy*fy0;
this.b = (int)(65536.0f*(a02*fdx + a12*fdy - t)/flensq);
| public void | paint(int x, int y, int width, int height, int[] minTouched, int[] maxTouched, int[] dst, int dstOffset, int dstScanlineStride)
int sx = x;
for (int j = 0; j < height; j++, y++) {
int minX = minTouched[j];
int maxX = maxTouched[j];
int w = (maxX >= minX) ? (maxX - minX + 1) : 0;
if (w + minX > width) {
w = width - minX;
}
int didx = dstOffset + minX;
x = sx + minX;
long frac = x*mx + y*my + b;
for (int i = 0; i < w; i++, didx++, x++) {
dst[didx] = colorMap.getColor((int)frac);
frac += mx;
}
dstOffset += dstScanlineStride;
}
| public void | setTransform(Transform6 transform)
super.setTransform(transform);
computeTransform();
|
|