500 // use the lookup table
501 r1 = LinearRGBtoSRGB[r1];
502 g1 = LinearRGBtoSRGB[g1];
503 b1 = LinearRGBtoSRGB[b1];
504
505 // re-compact the components
506 return ((a1 << 24) |
507 (r1 << 16) |
508 (g1 << 8) |
509 (b1 ));
510 }
511
512 /**
513 * Helper function to index into the gradients array. This is necessary
514 * because each interval has an array of colors with uniform size 255.
515 * However, the color intervals are not necessarily of uniform length, so
516 * a conversion is required.
517 *
518 * @param position the unmanipulated position, which will be mapped
519 * into the range 0 to 1
520 * @returns integer color to display
521 */
522 protected final int indexIntoGradientsArrays(float position) {
523 // first, manipulate position value depending on the cycle method
524 if (cycleMethod == CycleMethod.NO_CYCLE) {
525 if (position > 1) {
526 // upper bound is 1
527 position = 1;
528 } else if (position < 0) {
529 // lower bound is 0
530 position = 0;
531 }
532 } else if (cycleMethod == CycleMethod.REPEAT) {
533 // get the fractional part
534 // (modulo behavior discards integer component)
535 position = position - (int)position;
536
537 //position should now be between -1 and 1
538 if (position < 0) {
539 // force it to be in the range 0-1
540 position = position + 1;
|
500 // use the lookup table
501 r1 = LinearRGBtoSRGB[r1];
502 g1 = LinearRGBtoSRGB[g1];
503 b1 = LinearRGBtoSRGB[b1];
504
505 // re-compact the components
506 return ((a1 << 24) |
507 (r1 << 16) |
508 (g1 << 8) |
509 (b1 ));
510 }
511
512 /**
513 * Helper function to index into the gradients array. This is necessary
514 * because each interval has an array of colors with uniform size 255.
515 * However, the color intervals are not necessarily of uniform length, so
516 * a conversion is required.
517 *
518 * @param position the unmanipulated position, which will be mapped
519 * into the range 0 to 1
520 * @return integer color to display
521 */
522 protected final int indexIntoGradientsArrays(float position) {
523 // first, manipulate position value depending on the cycle method
524 if (cycleMethod == CycleMethod.NO_CYCLE) {
525 if (position > 1) {
526 // upper bound is 1
527 position = 1;
528 } else if (position < 0) {
529 // lower bound is 0
530 position = 0;
531 }
532 } else if (cycleMethod == CycleMethod.REPEAT) {
533 // get the fractional part
534 // (modulo behavior discards integer component)
535 position = position - (int)position;
536
537 //position should now be between -1 and 1
538 if (position < 0) {
539 // force it to be in the range 0-1
540 position = position + 1;
|