我正在尝试在画布上画一个笑脸。嘴巴需要看起来快乐或不快乐,取决于 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..
但是嘴巴看起来真的很像素化。有谁知道绘制曲线(椭圆的一半)的更好方法?