如何放大这个圆圈以便计算单个像素? 我在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 :(得分:0)
解决此问题的最简单方法是将Graphics对象强制转换为Graphics2D,然后使用scale(double,double)方法进行缩放。
// zooms in by a factor of 5 - call this method before rendering the circle
g2.scale(5, 5);