本文整理汇总了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;
}