Попытка создать сетку размером 2^n, задав пользователю «n». Я не закодирован в 2^n-части, что тоже немного смущает меня. Но сейчас моя доска не будет отображаться правильно, когда я получу ввод от пользователя. Моя drawLine - это диагональная линия, проходящая через всю доску.Возникли проблемы с сеткой создания drawPanel
Как получить правильное отображение платы?
Вот мой код:
import java.awt.*;
import java.util.*;
public class DrawingPanelTest2{
public static void main(String args[]){
// System.out.println("How big do you want your Tromino grid?");
// System.out.println("Please enter a perfect power of 2.");
// int size = stdin.nextInt();
//create a drawing panel of width=400px and height=400px
DrawingPanel panel = new DrawingPanel(400, 400);
//set the background of the panel to CYAN
panel.setBackground(Color.LIGHT_GRAY);
//create a graphic object for the panel
Graphics g = panel.getGraphics();
//draw square
drawFigure_1(g,0,0);
}
public static void drawFigure_1(Graphics g,int x, int y) {
Scanner stdin = new Scanner(System.in);
System.out.println("How big do you want your Tromino grid?");
System.out.println("Please enter a perfect power of 2.");
int size = stdin.nextInt();
//set your drawing color to red
g.setColor(Color.BLACK);
for (int i = 1; i <= size; i++) {
//draw a rectangle, (x,y) is the top-left cordiante of the rectangle, and ((i*z), (i*z))
//are the width and height of the rectangle
g.drawRect(x, y, i * size, i * size);
g.drawLine(x, y, i *size, i *size);
}
g.setColor(Color.BLACK);
}
}
Ты мужчина никогда не комментируй мой комментарий раньше !!!! – jSeesFor3ver
Теперь, когда у меня есть это, у меня есть программа для головоломок с тромминовым кодированием, но мне нужно комбинировать то, что у меня есть с графикой. Это то, что до меня дошло, я почти готов. Не могли бы вы посмотреть? http://stackoverflow.com/questions/19717359/tromino-program-using-graphics – jSeesFor3ver