我试图在画布上画笑脸。 根据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
我画嘴的方法做了这样的事情:
final RectF oval = new RectF();
if(intesity < 5){
oval.set(11, 12, 35, 35);
} etc..
但嘴巴看起来非常像素化。有谁知道绘制曲线的更好方法(椭圆的一半)?
答案 0 :(得分:2)
试试这个:
paint.setAntiAlias(true);
如果不能解决问题,请使用:
paint.setPathEffect(new CornerPathEffect(10));
希望这有帮助