facebook twitter hatena line email

Android/グラフィック/きらきら星

提供: 初心者エンジニアの簡易メモ
2015年5月20日 (水) 03:15時点における127.0.0.1 (トーク)による版 (ページの作成:「8方向にとんがりがあるキラキラ星 float x1; float y1; float x2; float y2; float x3; float y3; float rad; float rad2; float rad3; for (float i = 1;...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

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);
}