How to change the starting position of a path for addRoundRect?

Viewed 270

I'm making a Custom Square Progress bar with rounded corners using android Path class.

Problem

I'm facing a problem while changing the starting position of path for drawing a Round Rectangle when I call path.addRoundRect(...)

Code

    RectF rect = new RectF(0, 0, w, h);
    float inset = paint.getStrokeWidth();
    rect.inset(inset, inset);

    path.addRoundRect(rect, 15, 15, Path.Direction.CW);

    float length = new PathMeasure(path, false).getLength();
    
    float intervals{0, 0}
    intervals[0] = intervals[1] = length;

    PathEffect effect = new DashPathEffect(intervals, length - length * progress / 100);
    paint.setPathEffect(effect);
    
    canvas.draw(path, paint);

In below picture when the rectangle in drawn it starts drawing from red arrow but I want it to start from the position pointed by green arrow.

enter image description here

0 Answers
Related