本文整理汇总了Java中org.andengine.entity.primitive.Gradient类的典型用法代码示例。如果您正苦于以下问题:Java Gradient类的具体用法?Java Gradient怎么用?Java Gradient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gradient类属于org.andengine.entity.primitive包,在下文中一共展示了Gradient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onUpdateVertices
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Gradient pGradient) {
final float[] bufferData = this.mBufferData;
final float width = pGradient.getWidth(); // TODO Optimize with field access?
final float height = pGradient.getHeight(); // TODO Optimize with field access?
bufferData[(0 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X] = 0;
bufferData[(0 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y] = 0;
bufferData[(1 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X] = 0;
bufferData[(1 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y] = height;
bufferData[(2 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X] = width;
bufferData[(2 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y] = 0;
bufferData[(3 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X] = width;
bufferData[(3 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y] = height;
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:22,代码来源:HighPerformanceGradientVertexBufferObject.java
示例2: onUpdateVertices
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Gradient pGradient) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float width = pGradient.getWidth(); // TODO Optimize with field access?
final float height = pGradient.getHeight(); // TODO Optimize with field access?
bufferData.put((0 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X, 0);
bufferData.put((0 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y, 0);
bufferData.put((1 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X, 0);
bufferData.put((1 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y, height);
bufferData.put((2 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X, width);
bufferData.put((2 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y, 0);
bufferData.put((3 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_X, width);
bufferData.put((3 * Gradient.VERTEX_SIZE) + Gradient.VERTEX_INDEX_Y, height);
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:22,代码来源:LowMemoryGradientVertexBufferObject.java
示例3: onUpdateColor
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
@Override
public void onUpdateColor(final Gradient pGradient) {
final float[] bufferData = this.mBufferData;
final float gradientVectorX = pGradient.getGradientVectorX();
final float gradientVectorY = pGradient.getGradientVectorY();
final float length = MathUtils.length(gradientVectorX, gradientVectorY);
if (length == 0) {
return;
}
float dX = gradientVectorX / length;
float dY = gradientVectorY / length;
final float c = MathConstants.SQRT_2;
final float c2 = 2 * c;
if (pGradient.isGradientFitToBounds()) {
final float tmp = 1 / (Math.abs(dX) + Math.abs(dY));
dX *= tmp * c;
dY *= tmp * c;
}
final float fromRed = pGradient.getFromRed();
final float fromGreen = pGradient.getFromGreen();
final float fromBlue = pGradient.getFromBlue();
final float fromAlpha = pGradient.getFromAlpha(); // TODO * 'this.mOverallOpactity'
final float toRed = pGradient.getToRed();
final float toGreen = pGradient.getToGreen();
final float toBlue = pGradient.getToBlue();
final float toAlpha = pGradient.getToAlpha(); // TODO * 'this.mOverallOpactity'
/* Pre-fetch some calculations. */
final float dRed = fromRed - toRed;
final float dGreen = fromGreen - toGreen;
final float dBlue = fromBlue - toBlue;
final float dAlpha = fromAlpha - toAlpha;
final float v0 = (c + dX + dY) / c2;
bufferData[(0 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX] = ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v0), toGreen + (dGreen * v0), toBlue + (dBlue * v0), toAlpha + (dAlpha * v0));
final float v1 = (c + dX - dY) / c2;
bufferData[(1 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX] = ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v1), toGreen + (dGreen * v1), toBlue + (dBlue * v1), toAlpha + (dAlpha * v1));
final float v2 = (c - dX + dY) / c2;
bufferData[(2 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX] = ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v2), toGreen + (dGreen * v2), toBlue + (dBlue * v2), toAlpha + (dAlpha * v2));
final float v3 = (c - dX - dY) / c2;
bufferData[(3 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX] = ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v3), toGreen + (dGreen * v3), toBlue + (dBlue * v3), toAlpha + (dAlpha * v3));
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:57,代码来源:HighPerformanceGradientVertexBufferObject.java
示例4: onUpdateColor
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
@Override
public void onUpdateColor(final Gradient pGradient) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float gradientVectorX = pGradient.getGradientVectorX();
final float gradientVectorY = pGradient.getGradientVectorY();
final float length = MathUtils.length(gradientVectorX, gradientVectorY);
if (length == 0) {
return;
}
float dX = gradientVectorX / length;
float dY = gradientVectorY / length;
final float c = MathConstants.SQRT_2;
final float c2 = 2 * c;
if (pGradient.isGradientFitToBounds()) {
final float tmp = 1 / (Math.abs(dX) + Math.abs(dY));
dX *= tmp * c;
dY *= tmp * c;
}
final float fromRed = pGradient.getFromRed();
final float fromGreen = pGradient.getFromGreen();
final float fromBlue = pGradient.getFromBlue();
final float fromAlpha = pGradient.getFromAlpha(); // TODO * 'this.mOverallOpactity'
final float toRed = pGradient.getToRed();
final float toGreen = pGradient.getToGreen();
final float toBlue = pGradient.getToBlue();
final float toAlpha = pGradient.getToAlpha(); // TODO * 'this.mOverallOpactity'
/* Pre-fetch some calculations. */
final float dRed = fromRed - toRed;
final float dGreen = fromGreen - toGreen;
final float dBlue = fromBlue - toBlue;
final float dAlpha = fromAlpha - toAlpha;
final float v0 = (c + dX + dY) / c2;
bufferData.put((0 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX, ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v0), toGreen + (dGreen * v0), toBlue + (dBlue * v0), toAlpha + (dAlpha * v0)));
final float v1 = (c + dX - dY) / c2;
bufferData.put((1 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX, ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v1), toGreen + (dGreen * v1), toBlue + (dBlue * v1), toAlpha + (dAlpha * v1)));
final float v2 = (c - dX + dY) / c2;
bufferData.put((2 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX, ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v2), toGreen + (dGreen * v2), toBlue + (dBlue * v2), toAlpha + (dAlpha * v2)));
final float v3 = (c - dX - dY) / c2;
bufferData.put((3 * Gradient.VERTEX_SIZE) + Gradient.COLOR_INDEX, ColorUtils.convertRGBAToABGRPackedFloat(toRed + (dRed * v3), toGreen + (dGreen * v3), toBlue + (dBlue * v3), toAlpha + (dAlpha * v3)));
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:57,代码来源:LowMemoryGradientVertexBufferObject.java
示例5: onUpdateColor
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
public void onUpdateColor(final Gradient pGradient);
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:2,代码来源:IGradientVertexBufferObject.java
示例6: onUpdateVertices
import org.andengine.entity.primitive.Gradient; //导入依赖的package包/类
public void onUpdateVertices(final Gradient pGradient);
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:2,代码来源:IGradientVertexBufferObject.java
注:本文中的org.andengine.entity.primitive.Gradient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论