Android/グラフィック/きらきら星
提供: 初心者エンジニアの簡易メモ
8方向にとんがりがあるキラキラ星
float x1;
float y1;
float x2;
float y2;
float x3;
float y3;
float rad;
float rad2;
float rad3;
for (float i = 1; i <= 8; i++) {
rad = (float)(i * 45 / 180 * Math.PI);
rad2 = (i + 1) * 45 / 180 * Math.PI;
rad3 = (i - 1) * 45 / 180 * Math.PI;
x1 = (float)(len * Math.cos(rad) + x0);
y1 = (float)(len * Math.sin(rad) + y0);
x2 = (float)(len / 20 * Math.cos(rad2) + x0);
y2 = (float)(len / 20 * Math.sin(rad2) + y0);
x3 = (float)(len / 20 * Math.cos(rad3) + x0);
y3 = (float)(len / 20 * Math.sin(rad3) + y0);
canvas.drawLine(x1, y1, x2, y2, paint);
canvas.drawLine(x1, y1, x3, y3, paint);
}
