java五角星代码 java用星号输入五角星( 三 )


if (y1y2) {
double t = x1;
x1 = x2;
x2 = t;
t = y1;
y1 = y2;
y2 = t;
}
// 根据 y 方向的值求出 x 值,并填充图形
for (int i = (int) Math.round(y1); i = (int) Math.round(y2); i++) {
// 根据 x = (y - b) / a , 求 x
int y = (int) Math.round((i - b) / a);
int yy = radius - i;
int xx = radius + y;
yy = yy0 ? 0 : yy;
yy = yy2 * radius ? 2 * radius : yy;
xx = xx0 ? 0 : xx;
xx = xx2 * radius ? 2 * radius : xx;
canvas[yy][xx] = fillChar;
}
}
/**
* 将画完图之后的画布输出到控制台上
*
* @param canvas
*/
public static void printCanvas(char[][] canvas) {
for (int i = 0; icanvas.length; i++) {
for (int j = 0; jcanvas[i].length; j++) {
System.out.print(canvas[i][j]);
}
System.out.println();
}
}
}
public class Test {
public static void main(String[] args) {
// 画一个半径为10 , 旋转为0,空白为全身空格,填充为

推荐阅读