I am trying to draw this figure but I am unable to draw it.
I don't want to use any library. Just want to draw in canvas android.
Consider - center of circle is center of screen i.e. canvas.translate(centerX, centerY)
update :
@Override
protected void onDraw(Canvas canvas) {
radius = dip2px(getContext(), 150);//252
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
canvas.save();
canvas.translate(getWidth() / 2, getHeight() / 2);
for (int i = -35; i <= 215; i += 1) {
drawOuterLine(i, canvas);
}
canvas.restore();
}
private void drawOuterLine(int i, Canvas canvas) {
Paint paint2 = new Paint();
paint2.setAntiAlias(true);
paint2.setColor(getResources().getColor(R.color.ruler_white));
paint2.setStrokeWidth(dip2px(getContext(), 1));
Coordinate coordinate = getCoordinate(radius, i);
Coordinate coordinate1;
float x = coordinate.getX();
float y = coordinate.getY();
float r;
if (i == -35 || i == -11 || i == 15 || i == 39 || i == 65 || i == 89 || i == 115 || i == 139 || i == 165 || i == 189 || i == 215) {
r = radius - padding;
coordinate1 = getCoordinate(r, i);
float x1 = coordinate1.getX();
float y1 = coordinate1.getY();
canvas.drawLine(-x1, -y1, -x, -y, paint2);
String text = String.valueOf(showDegree[showDegreeCounter]);
if (showDegreeCounter<10) showDegreeCounter++;
Path path = getTextPath(text, mOutDegreePaint, i, radius
- padding - fontSize * 5 / 4);
canvas.drawTextOnPath(text, path, 0, 0, mOutDegreePaint);
} else if (i % 2 != 0) {
r = radius - padding * 3 / 5;
coordinate1 = getCoordinate(r, i);
float x1 = coordinate1.getX();
float y1 = coordinate1.getY();
canvas.drawLine(-x1, -y1, -x, -y, paint2);
}
}
Here is the snap I have achieved but the problem is those degrees are also being rotated and I don't want that. Please help me with this.