int width = projection.getWidth();
int height = projection.getHeight();
int[] pixels = new int[width * height];
OMRaster ret = new OMRaster((int) 0, (int) 0, width, height, pixels);
Debug.message("daynight", getName()
+ "|createImage: Center of bright spot lat= "
+ brightPoint.getLatitude() + ", lon= "
+ brightPoint.getLongitude());
// Light is clear and/or white
int light = daytimeColor.getRGB();
// Allocate the memory here for the testPoint
LatLonPoint testPoint = new LatLonPoint(0f, 0f);
// great circle distance between the bright point and each
// pixel.
float distance;
// Set the darkeness value
int dark = nighttimeColor.getRGB();// ARGB
int darkness = dark >>> 24;// darkness alpha
int value;
// Calculate the fae limits around the terminator
float upperFadeLimit = (float) (MoreMath.HALF_PI * (1.0 + termFade));
float lowerFadeLimit = (float) (MoreMath.HALF_PI * (1.0 - termFade));
int fadeColorValue = 0x00FFFFFF & (dark); // RGB
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
testPoint = projection.inverse(i, j, testPoint);
distance = GreatCircle.spherical_distance(brightPoint.radlat_,
brightPoint.radlon_,
testPoint.radlat_,
testPoint.radlon_);
if (distance > upperFadeLimit) {
pixels[j * width + i] = dark;
} else if (distance > lowerFadeLimit) {
value = (int) (darkness * (1 - ((upperFadeLimit - distance) / (upperFadeLimit - lowerFadeLimit))));
value <<= 24;
pixels[j * width + i] = fadeColorValue | value;
} else {
pixels[j * width + i] = light;
}
}
}
ret.generate(projection);
return ret;
}