Skip to content

Instantly share code, notes, and snippets.

@raghunandankavi2010
Created January 17, 2021 10:47
Show Gist options
  • Save raghunandankavi2010/b16d5f1d2c757e0b8335c03600f0b59d to your computer and use it in GitHub Desktop.
Save raghunandankavi2010/b16d5f1d2c757e0b8335c03600f0b59d to your computer and use it in GitHub Desktop.
Drawing ticks on circle circumference
for (int i = 0; i < TICK_COUNT; i++) {
float startAngle = (float) Math.toRadians(0f);
float angle = (float) ((startAngle + i) * (Math.toRadians(360)/TICK_COUNT));// * (Math.PI / TICK_COUNT));
int x = (int) ((radius* Math.cos(angle))+ cx);
int y = (int) ((radius* Math.sin(angle)) + cy);
int x1 = (int) (((radius+20)* Math.cos(angle))+ cx);
int y1= (int) (((radius+20)* Math.sin(angle)) + cy);
canvas.drawLine(
x,
y,
x1,
y1,
mTickPaint
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment