2014-07-07 1 views
0

이 원을 어떻게 확대하여 개별 픽셀 수를 계산할 수 있습니까? 저는 Minecraft에서 서클을 그리며 각 서클에 적합한 템플릿을 원합니다.이 원을 어떻게 확대하여 개별 픽셀을 셀 수 있습니까?

// Import the basic graphics classes. 
import java.awt.*; 
import javax.swing.*; 
public class BasicJPanel2 extends JPanel{ 


    private static final long serialVersionUID = 1L; 
// Create a constructor method 
    public BasicJPanel2(){ 
    super(); 
    } 

    public void paintComponent(Graphics g){ 

    // draw a circle 
    int upperLeft_x = 10; 
    int upperLeft_y = 20; 
    int width = 65; 
    int height = 65; 
    g.drawOval(upperLeft_x,upperLeft_y,width,height); // draw circle 

    } 

} 

답변

0

이 문제를 해결하는 가장 쉬운 방법은 확대 규모 (더블 더블) 방법을 사용 후, 그래픽이 Graphics2D의 반대 캐스트합니다.

// zooms in by a factor of 5 - call this method before rendering the circle 
g2.scale(5, 5); 
관련 문제