Canvas绘制基础

发布时间:2016-12-9 17:52:20 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"Canvas绘制基础",主要涉及到Canvas绘制基础方面的内容,对于Canvas绘制基础感兴趣的同学可以参考一下。

  //绘制像素点   canvas.drawPoint(float x, float y, Paint paint);   canvas.drawPoints(float[] pts, Paint paint);   canvas.drawPoints(f float[] pts, int offset, int count, paint paint); /** x:像素点横坐标 y:像素点纵坐标 pts:多个像素点的坐标,元素个数必须是偶数,两个一组为一个像素点的横纵坐标 paint:用来设置像素点的大小,颜色等属性 offset:drawPoints可以取pts数组中的一部分连续元素作为像素点的坐标,通过该参数指定第一个要获取的元素位置,若要获取从第三个元素开始,则设置为2 count:要获得数组的元素个数,必为偶数 **/ for example: protected void onDraw(Canvas canvas) {   super.onDraw(canvas);   float[] pts = {1,2,3,4,5,6,7,8};   int offset = 4;   int count = pts.length-4;   Paint paint = new Paint();   paint.setColor(Color.BLUE);   canvas.drawPoints(pts, offset, count, paint);  } //绘制线条和绘制像素点基本相同 像素点是两个float作为一组,而线条是四个float一组; //绘制圆形 canvas.drawCircle(x, y, 20, paint); 横纵坐标,半径; //绘制弧 protected void onDraw(Canvas canvas) {   super.onDraw(canvas);   float left = 1;   float top = 1;   float right = 100;   float bottom = 100;   RectF oval = new RectF(left, top, right, bottom);   float startAngle = 10;   float sweepAngle = 130;   boolean useCenter = true;   Paint paint = new Paint();   paint.setColor(Color.BLUE);   canvas.drawArc(oval, startAngle, sweepAngle, useCenter, paint);  } //绘制文本  canvas.drawText(text, x, y, paint);  canvas.drawPosText(text, pos, paint);  canvas.drawPosText(text, index, count, pos, paint);  

上一篇:计算机专业学习浅谈(zz)
下一篇:c#中字符串截取使用的方法

相关文章

关键词: Canvas绘制基础

相关评论