1

我正在尝试在画布上画一个笑脸。嘴巴需要看起来快乐或不快乐,取决于 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..

但是嘴巴看起来真的很像素化。有谁知道绘制曲线(椭圆的一半)的更好方法?

4

1 回答 1

2

尝试这个:

paint.setAntiAlias(true);

如果这不起作用,请使用以下方法:

paint.setPathEffect(new CornerPathEffect(10));

希望这可以帮助

于 2012-06-11T12:09:38.543 回答