2010-05-19 4 views
0

Graphics2D로 그리는 경우 AffineTransform을 사용합니다. 그것을 그리기 전에 Shape을 변형하기 위해 그것을 사용합니다. rx 및 ry는 회전으로 간주되지만 드로잉 할 때 셰이프는 회전되지 않고 전단됩니다. 로테이션을 적용하려면 어떻게해야합니까? 기본 생성자를 사용하여 회전, 크기 조정 및 변환을 호출했지만 모양이 보이지 않는 것처럼 보입니다.전단 대신 회전하도록 AffineTransform을 설정하는 방법은 무엇입니까?

transform = new AffineTransform(sx, rx, ry, sy, tx, ty); 
transform.createTransformedShape(shape); // Where shape is a GeneralPath instance 

답변

0

당신은

transform = g2d.getTransform(); 
transform.rotate(Math.toRadians(angleInDegree), pivotX, pivotY); 
g2d.setTransform(transform);  
// draw anything and it will be rotated based on rotate method 
transform.rotate(Math.toRadians(0), pivotX, pivotY); 
g2d.setTransform(transform); // now further drawing will no be drawn rotated 
처럼 회전 방법을 사용할 수 있습니다
관련 문제