Question: & FractalDrawer Class ( 4 5 Points ) centuries because of their interesting mathematical properties and often appear in natural objects ( e . g
& FractalDrawer Class Points
centuries because of their interesting mathematical properties and often appear in natural objects eg snow flakes, plants Fractals are also a classic application of recursion; you can read more about fractals and their
history here. Consider the example below, which illustrates the process of constructing a fractal composed of triangles at several steps in the process. Notice that at each step, triangles of increasingly smaller sizes are drawn
at the three points of each existing triangle. More examples of fractals can be found at the end of this document.
Triangle fractal example
To help you with the drawing, we've already implemented a Canvas class that supports all of the drawing capability you need. You should look at the code if you're interested, but all you'll need to know is how you can interact
with Canvas objects.
Here are the method specifications of the Canvas class:
Canvas defaulticonstructor: Creates a canvas of default size pixels pixels
Canvas int height, int width : Creates a canvas of specified height and width.
: void drawShapeCircle circleObj : Draws the passed in Circle object.
void drawShapeTriangle triangleObj : Draws the passed in Triangle object.
void drawShapeRectangle Rectang leObj : Draws the passed in Rectangle object.
Each of the drawing methods will draw the shape you pass in This method accesses the color, position, and other attributes of the shape to draw it on the canvas.
Here's an example of how you might use the Canvas class to draw a single blue circle:
Canvas drawing new Canvas ;
Gircle myCircle new Circle ;
myCircle. setColor BLUE;
drawing.drawShape;
TI IMPORTANT: JavaJFrame uses a coordinate system where the origin is in the upper lefthand corner. As cither the x andor increases, the shape will move right andor down. See the visual below.
Disual of JavaJFrame coordinate system
You will be responsible for filling in the FractalDrawer class.
For full credit, your program should have the following features:
another
IMPORTANT: The pattern must repeat on itself using recursion for full credit. Changing a shape's size or position should be involved in recursive calls.
Draw at least four shapes per layer for rectangles and circles and at least three per layer for triangles eg draw the new shapes on all three points or sides of a triangle, or on four opposite sides of a circle again,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
