I have a function that draws a text on a canvas with drawTextOnPath
. I calculated offset everything works fine, but I want to draw it in a particular way. Currently texts rotation offset is equal to circles offset. I want to rotate the text by 90/45 degrees. But I can not figure out how.
Please any ideas.
private void drawLegend(Canvas canvas) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.rotate(-228, centerX, centerY);
Path circle = new Path();
double halfCircumference = (radius * 2 * Math.PI) - ((radius * 2 * Math.PI) / 8) * 2;
double increments = 5;
for (int i = 0; i <= this.mMaxSpeed; i += increments) {
circle.addCircle(centerX, centerY, radius, Path.Direction.CW);
canvas.drawTextOnPath(String.format("%d", i),
circle,
(float) (i * halfCircumference / this.mMaxSpeed),
-20f,
scalePaint);
}
canvas.restore();
}