本文整理汇总了Java中org.lwjgl.util.ReadableColor.getGreen方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableColor.getGreen方法的具体用法?Java ReadableColor.getGreen怎么用?Java ReadableColor.getGreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.util.ReadableColor
的用法示例。
在下文中一共展示了ReadableColor.getGreen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initColorMap
import org.lwjgl.util.ReadableColor; //导入方法依赖的package包/类
private static void initColorMap(IntBuffer colorMap, int stepSize, ReadableColor... colors) {
for ( int n = 0; n < colors.length - 1; n++ ) {
ReadableColor color = colors[n];
int r0 = color.getRed();
int g0 = color.getGreen();
int b0 = color.getBlue();
color = colors[n + 1];
int r1 = color.getRed();
int g1 = color.getGreen();
int b1 = color.getBlue();
int deltaR = r1 - r0;
int deltaG = g1 - g0;
int deltaB = b1 - b0;
for ( int step = 0; step < stepSize; step++ ) {
float alpha = (float)step / (stepSize - 1);
int r = (int)(r0 + alpha * deltaR);
int g = (int)(g0 + alpha * deltaG);
int b = (int)(b0 + alpha * deltaB);
colorMap.put((r << 0) | (g << 8) | (b << 16));
}
}
}
示例2: interpolate
import org.lwjgl.util.ReadableColor; //导入方法依赖的package包/类
/**
* Interpolates between the given {@link Color}s according to the given
* amount. The amount should be between 0 and 1, all other numbers are produce
* undefined results.
*
* @param col1 The first {@link Color} in the interpolation.
* @param col2 The second {@link Color} in the interpolation.
* @param amt The amount to interpolate.
* @param out The {@link Color} to store the output in.
* @return The interpolated {@link Color}.
*/
public static Color interpolate(ReadableColor col1, ReadableColor col2, float amt, Color out) {
int num = (int) (col1.getAlpha() * (1 - amt) + col2.getAlpha() * amt);
out.setAlpha(num);
num = (int) (col1.getRed()* (1 - amt) + col2.getRed() * amt);
out.setRed(num);
num = (int) (col1.getGreen()* (1 - amt) + col2.getGreen() * amt);
out.setGreen(num);
num = (int) (col1.getBlue()* (1 - amt) + col2.getBlue() * amt);
out.setBlue(num);
return out;
}