1

I'm designing a custom widget which have a gauge similar to this blue one : gauge (except this is a continuous gauge and not a splited one)

I tried to draw a path with two arcs :

private void drawGauge(Canvas canvas) {
        canvas.save(Canvas.MATRIX_SAVE_FLAG);
        float degreesToDraw = positionToDegree();
        gaugePath.addArc(secondArcRect, 90, degreesToDraw);
        gaugePath.addArc(faceRect, 90, degreesToDraw);
        gaugePath.close();
        canvas.drawPath(gaugePath, gaugePaint);
        canvas.restore();
    }

my two arcs are well drawn but the gaugePath.close() don't work as excepted since it close the path with the gauge start points (lower points). What I want is to draw a line between the two end points of the arcs(the higher points).

Unfortunately, I've no idea about how to find their coordinates to draw this wanted line.

FYI, I'm currently drawing this : enter image description here

Any idea/help ? :)

Magnas
  • 869
  • 1
  • 5
  • 18

1 Answers1

1

The trouble was that faceRect and secondArcRect hadn't their center aligned on the y axis. Simply fixing this and making them sharing the same y position for their bottom-right point(to have the two arcs cross themselves at the start and then fill properly) is enough

Magnas
  • 869
  • 1
  • 5
  • 18