How to draw a half oval on a canvas

I'm trying to draw a smiley on a canvas. The mouth needs to look happy or not happy depending of a integer between 0-100. the following code draws the smiley:

    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

My method to draw a mouth does something like this atm:

  final RectF oval = new RectF();
    if(intesity < 5){
        oval.set(11, 12, 35, 35);
    } etc..

But the mouth looks really pixellated. Does anyone knows a better way to draw a curved line (halve of a oval)?

Answers


Try this:

paint.setAntiAlias(true);

If that doesn´t do the trick use this:

paint.setPathEffect(new CornerPathEffect(10));

Hope this helps


Need Your Help

Unsemantic grid framework doesn't seem to create gutters

html css frameworks css-frameworks unsemantic-css

This question relates to the Unsemantic Grid Framework (unsemantic.com).

HTTP in C: Why do I have to call recv() multiple times?

c sockets http web winsock2

I've started to learn about Network programming in C (sockets), and Internet protocols.