
위와같은 화면을 canvas와 paint로 그렸는데
저 상태에서 회전하는걸 보여주고 싶습니다.
어떻게 하면 될까요?ㅜ
위에 스샷은 밑에 있는 소스로 setContentView(new MyCanvasView(this)); 호출로 만들엇습니다.
protected class MyCanvasView extends View{
public MyCanvasView(Context context) {
super(context);
}
public void onDraw(Canvas canvas) {
int cx = getWidth() / 2; // View 의 중심점
int cy = getHeight() / 2;
int w = 0;
int h = 0;
int DIRECTION = 1; // 이미지 선택 (위의 이미지 1~4)
Bitmap bitmap = null;
Paint paint = new Paint();
int icnt = canvas.save();
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
paint.setColor(Color.BLACK);
canvas.drawRect(0, 0, display.getWidth(), display.getHeight(), paint);
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE); // 외곽선만 그린다
canvas.drawColor(Color.WHITE); // View를 흰색으로 채우기
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setStrokeWidth(20);
for (int i = 1; i <= 24; i++) { // 20도 간격으로 회전하면 18번 반복
canvas.rotate(15, cx, cy); // Canvas를 중심점을 회전축으로 20도 회전
canvas.drawLine(cx, cy, 4000, 4000, paint);
}
paint.setColor(Color.GRAY);
paint.setStrokeWidth(30);
paint.setDither(true);
canvas.drawCircle(cx, cy, 30, paint);
} // onDraw
}