Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何放大这个圆,以便计算各个像素?_Java - Fatal编程技术网

Java 如何放大这个圆,以便计算各个像素?

Java 如何放大这个圆,以便计算各个像素?,java,Java,如何放大这个圆,以便计算各个像素? 我在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

如何放大这个圆,以便计算各个像素? 我在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

  }

}

解决此问题的最简单方法是将图形对象强制转换为Graphics2D,然后使用scaledouble、double方法进行缩放

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