I want to draw a graphics pattern as below image.
My problem is how to draw these triangles that connected with square.
My java code is below.
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class Shape extends Applet {
private static final long serialVersionUID = 1L;
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g; // turn on antialiasing
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.YELLOW);
int xPoly[] = {60, 140, 100};
int yPoly[] = {60, 60, 30};
g.fillRect(20,20,160,160);
g.setColor(Color.PINK); // draw the shapes
g.fillOval(20,20,160,160);
g.setColor(Color.CYAN);
g.fillRect(60,60,80,80);
g.setColor(Color.BLACK);
g.drawPolygon(xPoly, yPoly, xPoly.length);
g.setColor(Color.RED);
g.fillOval(60,60,80,80);
}
}
Please help me to draw these triangles. I'll appreciate your help.