import java.applet.*; import java.awt.*; import java.awt.event.*; import java.lang.System; import java.util.ArrayList; import javax.swing.*; /* */ public class M0103225_5 extends Applet { static int WIDTH, HEIGHT; // 画面サイズ Graphics offg; Image offi; Point c = new Point(); Point p1[] = new Point[6]; Point p2[][] = new Point[6][6]; Point p3[][][] = new Point[6][6][6]; Point p4[][][][] = new Point[6][6][6][6]; Point p5[][][][][] = new Point[6][6][6][6][6]; Point p[] = new Point[6]; int[] nx1 = new int[3]; int[] ny1 = new int[3]; int[] nx2 = new int[3]; int[] ny2 = new int[3]; int r = 300; public void init() { WIDTH = 400; HEIGHT = 400; for(int i = 0; i<6; i++){ p1[i] = new Point(); for(int j = 0; j<6; j++){ p2[i][j] = new Point(); for(int k=0; k<6; k++){ p3[i][j][k] = new Point(); for(int l=0; l<6; l++){ p4[i][j][k][l] = new Point(); for(int m=0; m<6; m++){ p5[i][j][k][l][m] = new Point(); } } } } p[i] = new Point(); } offi = createImage(WIDTH, HEIGHT); offg = offi.getGraphics(); update(offg); } public void paint(Graphics g) { c.x = 300; c.y = 300; setVertex1(g); setVertex2(g); setVertex3(g); setVertex4(g); setVertex5(g); //p = p1; //g.setColor(new Color(50, 50, 150)); //createTriangle(g, p); for(int i = 0; i<6; i++){ for(int j = 0; j<6; j++){ p[j] = p2[i][j]; } g.setColor(new Color(150, 80, 200)); createStar(g, p); } for(int i = 0; i<6; i++){ for(int j = 0; j<6; j++){ for(int k = 0; k<6; k++){ p[k] = p3[i][j][k]; } g.setColor(new Color(100, 100, 230)); createStar(g, p); } } for(int i = 0; i<6; i++){ for(int j = 0; j<6; j++){ for(int k = 0; k<6; k++){ for(int l=0; l<6; l++){ p[l] = p4[i][j][k][l]; } g.setColor(new Color(125, 125, 255)); createStar(g, p); } } } for(int i = 0; i<6; i++){ for(int j = 0; j<6; j++){ for(int k = 0; k<6; k++){ for(int l=0; l<6; l++){ for(int m=0; m<6; m++){ p[m] = p5[i][j][k][l][m]; } g.setColor(new Color(200, 200, 255)); createStar(g, p); } } } } } public void setVertex1(Graphics g){ int radius = r; for(int i=0; i<6; i++){ p1[i].x = (int)(c.x + radius * Math.cos(Math.PI * i / 3.0 + Math.PI/6)); p1[i].y = (int)(c.y + radius * Math.sin(Math.PI * i / 3.0 + Math.PI/6)); } } public void setVertex2(Graphics g){ int radius = (int)(r/3); for(int i=0; i<6; i++){ for(int j=0; j<6; j++){ p2[i][j].x = (int)((p1[i].x-c.x)*2/3+c.x + radius * Math.cos(Math.PI * j / 3.0 + Math.PI/6)); p2[i][j].y = (int)((p1[i].y-c.y)*2/3+c.y + radius * Math.sin(Math.PI * j / 3.0 + Math.PI/6)); } } } public void setVertex3(Graphics g){ int radius = (int)(r/9); for(int i=0; i<6; i++){ for(int j=0; j<6; j++){ for(int k=0; k<6; k++){ p3[i][j][k].x = (int)((p2[i][j].x-c.x)*2/3+c.x + radius * Math.cos(Math.PI * k / 3.0 + Math.PI/6)); p3[i][j][k].y = (int)((p2[i][j].y-c.y)*2/3+c.y + radius * Math.sin(Math.PI * k / 3.0 + Math.PI/6)); } } } } public void setVertex4(Graphics g){ int radius = (int)(r/27); for(int i=0; i<6; i++){ for(int j=0; j<6; j++){ for(int k=0; k<6; k++){ for(int l=0; l<6; l++){ p4[i][j][k][l].x = (int)((p3[i][j][k].x-c.x)*2/3+c.x + radius * Math.cos(Math.PI * l / 3.0 + Math.PI/6)); p4[i][j][k][l].y = (int)((p3[i][j][k].y-c.y)*2/3+c.y + radius * Math.sin(Math.PI * l / 3.0 + Math.PI/6)); } } } } } public void setVertex5(Graphics g){ int radius = (int)(r/81); for(int i=0; i<6; i++){ for(int j=0; j<6; j++){ for(int k=0; k<6; k++){ for(int l=0; l<6; l++){ for(int m=0; m<6; m++){ p5[i][j][k][l][m].x = (int)(p4[i][j][k][l].x + radius * Math.cos(Math.PI * m / 3.0 + Math.PI/6)); p5[i][j][k][l][m].y = (int)(p4[i][j][k][l].y + radius * Math.sin(Math.PI * m / 3.0 + Math.PI/6)); } } } } } } public void createStar(Graphics g, Point n[]){ nx1[0] = n[0].x; nx1[1] = n[2].x; nx1[2] = n[4].x; nx2[0] = n[1].x; nx2[1] = n[3].x; nx2[2] = n[5].x; ny1[0] = n[0].y; ny1[1] = n[2].y; ny1[2] = n[4].y; ny2[0] = n[1].y; ny2[1] = n[3].y; ny2[2] = n[5].y; g.fillPolygon(nx1, ny1, 3); g.fillPolygon(nx2, ny2, 3); } public void update(Graphics g) { paint(g); } }