Java 类android.graphics.Canvas.VertexMode 实例源码

项目:meeting-room-tablet    文件:CalendarVisualizer.java   
private void drawCalendarReservations(Canvas c, RectF area) {
    c.save();
    c.clipRect(area.left + getScrollX(), area.top, area.right + getScrollX(), area.bottom);
    c.translate(area.left, area.top);
    int height = (int) area.height();
    if (reservations.length > 0) {
        float[] points = new float[reservations.length * 8];
        short[] indices = new short[reservations.length * 6];
        for (int i = 0; i < reservations.length; i++) {
            int j = 8 * i;
            //order of points is top-left, top-right, bottom-left, bottom-right
            points[j] = getXForTime(reservations[i].getStartTime());
            points[j + 1] = getProportionalY(reservations[i].getStartTime()) * height;
            points[j + 2] = getXForTime(reservations[i].getStartTime()) + dayWidth;
            points[j + 3] = points[j + 1];
            points[j + 4] = points[j];
            points[j + 5] = getProportionalEndY(reservations[i].getEndTime()) * height;
            points[j + 6] = points[j + 2];
            points[j + 7] = points[j + 5];
            j += 8;
            //top-left * 2, top-right, bottom-left, bottom-right * 2
            // *2 makes reservation connecting triangles zero area
            int p = 6 * i;
            short vi = (short) (4 * i); //each reservation needs 4 vertices
            indices[p] = vi;
            indices[p + 1] = vi;
            indices[p + 2] = (short) (vi + 1);
            indices[p + 3] = (short) (vi + 2);
            indices[p + 4] = (short) (vi + 3);
            indices[p + 5] = (short) (vi + 3);
        }
        c.drawVertices(VertexMode.TRIANGLE_STRIP, points.length, points, 0,
                points, 0, null, 0, indices, 0, indices.length, markerPaint);

        Paint linePaint = new Paint();
        // linePaint.setARGB(200, 255, 255, 255);
        linePaint.setColor(Color.WHITE);

        // Draw the separator line only if the next reservation is following this one immediately.
        for (int i = 0; i < reservations.length; i++) {
            if ((i + 1) < reservations.length &&
                    reservations[i].getEndTime().getTimeInMillis() == reservations[i + 1].getStartTime().getTimeInMillis()) {
                c.drawLine(getXForTime(reservations[i].getStartTime()),
                        getProportionalEndY(reservations[i].getEndTime()) * height,
                        getXForTime(reservations[i].getStartTime()) + dayWidth,
                        getProportionalEndY(reservations[i].getEndTime()) * height,
                        linePaint);
            }
        }

    }
    c.restore();
}
项目:rastertheque    文件:ISafeCanvas.java   
/**
 * Draw the array of vertices, interpreted as triangles (based on mode). The verts array is
 * required, and specifies the x,y pairs for each vertex. If texs is non-null, then it is used
 * to specify the coordinate in shader coordinates to use at each vertex (the paint must have a
 * shader in this case). If there is no texs array, but there is a color array, then each color
 * is interpolated across its corresponding triangle in a gradient. If both texs and colors
 * arrays are present, then they behave as before, but the resulting color at each pixels is
 * the
 * result of multiplying the colors from the shader and the color-gradient together. The
 * indices
 * array is optional, but if it is present, then it is used to specify the index of each
 * triangle, rather than just walking through the arrays in order.
 *
 * @param mode How to interpret the array of vertices
 * @param vertexCount The number of values in the vertices array (and corresponding texs and
 * colors
 * arrays if non-null). Each logical vertex is two values (x, y), vertexCount must be
 * a multiple of 2.
 * @param verts Array of vertices for the mesh
 * @param vertOffset Number of values in the verts to skip before drawing.
 * @param texs May be null. If not null, specifies the coordinates to sample into the current
 * shader (e.g. bitmap tile or gradient)
 * @param texOffset Number of values in texs to skip before drawing.
 * @param colors May be null. If not null, specifies a color for each vertex, to be
 * interpolated
 * across the triangle.
 * @param colorOffset Number of values in colors to skip before drawing.
 * @param indices If not null, array of indices to reference into the vertex (texs, colors)
 * array.
 * @param indexCount number of entries in the indices array (if not null).
 * @param paint Specifies the shader to use if the texs array is non-null.
 */
public abstract void drawVertices(VertexMode mode, int vertexCount, double[] verts,
        int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset,
        short[] indices, int indexOffset, int indexCount, SafePaint paint);
项目:OpenMapKitAndroid    文件:ISafeCanvas.java   
/**
 * Draw the array of vertices, interpreted as triangles (based on mode). The verts array is
 * required, and specifies the x,y pairs for each vertex. If texs is non-null, then it is used
 * to specify the coordinate in shader coordinates to use at each vertex (the paint must have a
 * shader in this case). If there is no texs array, but there is a color array, then each color
 * is interpolated across its corresponding triangle in a gradient. If both texs and colors
 * arrays are present, then they behave as before, but the resulting color at each pixels is
 * the
 * result of multiplying the colors from the shader and the color-gradient together. The
 * indices
 * array is optional, but if it is present, then it is used to specify the index of each
 * triangle, rather than just walking through the arrays in order.
 *
 * @param mode How to interpret the array of vertices
 * @param vertexCount The number of values in the vertices array (and corresponding texs and
 * colors
 * arrays if non-null). Each logical vertex is two values (x, y), vertexCount must be
 * a multiple of 2.
 * @param verts Array of vertices for the mesh
 * @param vertOffset Number of values in the verts to skip before drawing.
 * @param texs May be null. If not null, specifies the coordinates to sample into the current
 * shader (e.g. bitmap tile or gradient)
 * @param texOffset Number of values in texs to skip before drawing.
 * @param colors May be null. If not null, specifies a color for each vertex, to be
 * interpolated
 * across the triangle.
 * @param colorOffset Number of values in colors to skip before drawing.
 * @param indices If not null, array of indices to reference into the vertex (texs, colors)
 * array.
 * @param indexCount number of entries in the indices array (if not null).
 * @param paint Specifies the shader to use if the texs array is non-null.
 */
public abstract void drawVertices(VertexMode mode, int vertexCount, double[] verts,
        int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset,
        short[] indices, int indexOffset, int indexCount, SafePaint paint);