當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.drawPoints方法代碼示例

本文整理匯總了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));
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:24,代碼來源:UDCanvas.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Building-Android-UIs-with-Custom-Views,代碼行數:23,代碼來源:PrimitiveDrawer.java

示例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);
}
 
開發者ID:songjiabin,項目名稱:MySelfDemo,代碼行數:16,代碼來源:MyView2.java

示例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;
}
 
開發者ID:52inc,項目名稱:CanvasScript,代碼行數:10,代碼來源:PointParams.java


注:本文中的android.graphics.Canvas.drawPoints方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。