本文整理汇总了Java中android.graphics.Canvas.drawVertices方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawVertices方法的具体用法?Java Canvas.drawVertices怎么用?Java Canvas.drawVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.drawVertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDraw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
assert(mVertexPoints != null);
// Colors for each vertex
int[] mFillColors = new int[mVertexPoints.length];
for (int triangle = 0; triangle < mColors.length; triangle++) {
// Set color for all vertex points to current triangle color
Arrays.fill(mFillColors, mColors[triangle]);
// Draw one triangle
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, mVertexPoints.length, mVertexPoints,
0, null, 0, // No Textures
mFillColors, 0, mIndices,
triangle * 2, 3, // Use 3 vertices via Index Array with offset 2
new Paint());
}
}
示例2: drawVertices
import android.graphics.Canvas; //导入方法依赖的package包/类
protected void drawVertices(Canvas canvas, int count, int[] poly_x, int[] poly_y, int[] col)
{
vertsValues[0] = poly_x[0];
vertsValues[1] = poly_y[0];
vertsValues[2] = poly_x[1];
vertsValues[3] = poly_y[1];
vertsValues[4] = poly_x[2];
vertsValues[5] = poly_y[2];
vertsValues[6] = poly_x[0];
vertsValues[7] = poly_y[0];
vertsValues[8] = poly_x[3];
vertsValues[9] = poly_y[3];
vertsValues[10] = poly_x[2];
vertsValues[11] = poly_y[2];
if (col != null)
{
vertsColors[0] = col[0];
vertsColors[1] = col[1];
vertsColors[2] = col[2];
vertsColors[3] = col[0];
vertsColors[4] = col[3];
vertsColors[5] = col[2];
vertsColors[6] = 0xFF000000;
vertsColors[7] = 0xFF000000;
vertsColors[8] = 0xFF000000;
vertsColors[9] = 0xFF000000;
vertsColors[10] = 0xFF000000;
vertsColors[11] = 0xFF000000;
}
else
{
for (int i = 0; i < vertsColors.length; i++)
{
vertsColors[i] = paint.getColor();
}
}
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, vertsValues.length, vertsValues, 0, null, 0, vertsColors, 0,
null, 0, 0, paint);
}