本文整理匯總了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);
}