I HAVE TO USE APPLET NOT JFRAME JPANEL OR ANYTHING ELSE I HA
************************************************I HAVE TO USE APPLET, NOT JFRAME, JPANEL, OR ANYTHING ELSE. I HAVE TO USE APPLET. AND I HAVE TO USE THE METHODS HE GIVES IN THE HINT SECTION. ALSO I HAVE LOOKED AT OTHER CHEGG ANSWERS ON THIS WEBSITE AND THEY DO NOT USE APPLET. I NEED TO USE APPLET. PLEASE DO NOT JUST COPY AND PASTE ANOTHER ANSWER FROM SOMEWHERE ELSE UNLESS YOU ARE USING APPLET!!!!!*******************************************************
Objective:
Write a program in which draws (yes it actually makes a picture) a triangular fractal using recursion. This is best if done using a java applet.
Suggested Methodology
The idea for it is this
First draw a filled equilateral triangle
Next draw another filled equilateral triangle of a different color that’s upside down in the middle of that triangle
Using the other triangles formed repeat step 2 until a pixel limit of 4 is reached
HINTS:
It may be a good idea to look at the examples I gave 02/12/2015
The method fillPolygon(int[] xPoints, int[] yPoint, numberOfPoints) as called by the graphics device is important
The method setColor(Color aColor) is important for picking different colors to draw things.
Example Image of Results:
AASASolution
import java.awt.*;
import java.applet.*;
public class SierpinskiTriangle extends Applet private Graphics g;
private int dMin=4; // limit to recursion in pixels
public void paint(Graphics g)
this.g = g;
int d = 1024; // basis (width of the triangle)
int x0 = 50; // distance from the left
int y0 = 50; // distance from the top
int h = (int)(d*Math.sqrt(3)/2); // height // so: suitable for an equilateral triangle
int xA=x0, yA=y0+h; // (bottom-left)
int xB=x0+d, yB=y0+h; // (bottom-right)
int xC=x0+d/2, yC=y0; // equilateral triangle (top-center)
int[] x = xA, xB, xC ;
int[] y = yA, yB, yC ;
drawSierpinskiTriangle( x, y, d/2 ); // start recursion
private void drawSierpinskiTriangle ( int[] x, int[] y, int d )
if (d<=dMin) g.fillPolygon ( x, y, 3 ); // bottom of the recursion else

