我想在画布上画个笑脸。嘴巴需要看起来高兴或不高兴,这取决于0-100之间的整数。下面的代码绘制笑脸:
paint.setStyle(Paint.Style.FILL);
paint.setColor(getColorByIntesity(intesity));
canvas.drawCircle(23, 23, 20, paint);
paint.setColor(Color.BLACK);
canvas.drawCircle(15, 15, 3, paint); //Left eye
canvas.drawCircle(31, 15, 3, paint); //Right eye
paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(23, 23, 20, paint);
if(intesity >= 55)
canvas.drawArc(getMouthDrawingByIntesity(intesity), 180, 180, false, paint); //Mouth
else if(intesity < 55)
canvas.drawArc(getMouthDrawingByIntesity(intesity), 0, 180, false, paint); //Mouth我画嘴巴的方法类似于下面的atm:
final RectF oval = new RectF();
if(intesity < 5){
oval.set(11, 12, 35, 35);
} etc..但是嘴巴看起来真的像像素一样。有没有人知道更好的画曲线(椭圆的一半)的方法?
发布于 2012-06-11 20:09:39
试试这个:
paint.setAntiAlias(true);如果这还不起作用,使用下面的代码:
paint.setPathEffect(new CornerPathEffect(10));希望这能有所帮助
https://stackoverflow.com/questions/10979757
复制相似问题