本文整理匯總了Java中android.graphics.Canvas.drawPoints方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.drawPoints方法的具體用法?Java Canvas.drawPoints怎麽用?Java Canvas.drawPoints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.drawPoints方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawPoints
import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawPoints(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
final float pts[] = new float[keys.length * 2];
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 2) {
for (int j = 0; j < 2; j++) {
pts[i * 2 + j] = DimenUtil.dpiToPx(value.get(j + 1));
}
}
}
canvas.drawPoints(pts, getDefaultPaint(config));
}
}
}
}
示例2: onDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(BACKGROUND_COLOR);
if (points == null) {
points = new float[POINTS * 2];
for(int i = 0; i < POINTS; i++) {
points[i * 2 ] = (float) Math.random() * getWidth();
points[i * 2 + 1] = (float) Math.random() * getHeight();
}
}
paint.setColor(0xffa0a0a0);
paint.setStrokeWidth(4.f);
paint.setStrokeCap(Paint.Cap.BUTT);
canvas.drawLines(points, paint);
paint.setColor(0xffffffff);
paint.setStrokeWidth(10.f);
paint.setStrokeCap(Paint.Cap.ROUND);
canvas.drawPoints(points, paint);
}
示例3: drawPoints
import android.graphics.Canvas; //導入方法依賴的package包/類
/**
* 畫多個 點兒 再進行點兒的連接
*
* @param canvas
*/
private void drawPoints(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.parseColor("#FF7F24"));
paint.setStrokeWidth(20);
paint.setStrokeCap(Paint.Cap.ROUND);
float[] points = {0, 0, 50, 50, 50, 100, 100, 50, 100, 100, 150, 50, 150, 100}; // 繪製四個點:(50, 50) (50, 100) (100, 50) (100, 100)
canvas.drawPoints(points, 2 /* 跳過兩個數,即前兩個 0 */,
8 /* 一共繪製 8 個數(4 個點)*/, paint);
}
示例4: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public int draw(Canvas canvas) {
if (count == 2) {
canvas.drawPoint(pts[0], pts[1], paint);
} else {
canvas.drawPoints(pts, offset, count, paint);
}
return NO_SAVE;
}