微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,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,null,indices,indices.length,markerPaint);

        Paint linePaint = new Paint();
        // linePaint.setARGB(200,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,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,SafePaint paint);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。