Write a program that draws a square fractal. Fractals are images that keep repeating their own image in ever-smaller versions. There exists numerous fractals and some fractals rely on computation of advanced mathematics. All fractals have a recursive quality and provide an ideal platform for practicing recursive concepts. You will note that from the four corners of the center rectangle, smaller rectangles are drawn and each rectangle in turn continues to draw three smaller rectangles until the rectangle is the size of one pixel.  A CODE TEMPLATE & PICTURE OF OUTPUT IS ALREADY PROVIDED IN THE ATTACHED PICTURES Method drawSquare1 gets the ball rolling and draws a solid rectangle in the center of the screen.  The initial rectangle needs to be 1/4 the size of the monitor. This explains why it is important to know the screen resolution and why this information is passed by parameter. Method drawSquare1 needs to make four method calls to draw each one of the four rectangles attached to the initial rectangle. Each one of the succeeding rectangles is half the width and height of the preceding rectangle. The delay method is provided so that you can observe the recursive sequence as the fractal picture is drawn. You need to experiment with the delay value, which depends on the speed of your computer. It is often the case that the applet window size is smaller than the monitor resolution. If such is the case use the applet window resolution values in the paint method.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a program that draws a square fractal. Fractals are images that keep repeating their own image in ever-smaller versions. There exists numerous fractals and some fractals rely on computation of advanced mathematics. All fractals have a recursive quality and provide an ideal platform for practicing recursive concepts. You will note that from the four corners of the center rectangle, smaller rectangles are drawn and each rectangle in turn continues to draw three smaller rectangles until the rectangle is the size of one pixel. 

A CODE TEMPLATE & PICTURE OF OUTPUT IS ALREADY PROVIDED IN THE ATTACHED PICTURES

Method drawSquare1 gets the ball rolling and draws a solid rectangle in the center of the screen.  The initial rectangle needs to be 1/4 the size of the monitor. This explains why it is important to know the screen resolution and why this information is passed by parameter. Method drawSquare1 needs to make four method calls to draw each one of the four rectangles attached to the initial rectangle. Each one of the succeeding rectangles is half the width and height of the preceding rectangle. The delay method is provided so that you can observe the recursive sequence as the fractal picture is drawn. You need to experiment with the delay value, which depends on the speed of your computer. It is often the case that the applet window size is smaller than the monitor resolution. If such is the case use the applet window resolution values in the paint method.

Lab10vst.java Provided Starting File
// Lab10vst.java
// The student, starting version of the Lab10 assignment.
import java.aut;
import java.arrist.";
public class Lab10vst extends Applet
{
public void paint (Graphics g)
{
drawSquare1 (g, 1024,768);
}
public void drawSquare1(Graphics g, int maxx, int maxX)
{
}
int mid
maxX/2;
=
maxX/2;
int midy
int stactwidth
=
maxX/4;
int stactheight = maxX/4;
int tlx = midx- (stantWidth/2):
int tX midy. (startHeight/2);
fillest (tlx.tlX.startwidth.startHeight);
public void delay(long n)
{
}
n* 1000;
System.naneTime(
long startRelax
long endRelax = li
while (endRelax - startRelax <n)
System.paneTime();
endRelay =
=
Transcribed Image Text:Lab10vst.java Provided Starting File // Lab10vst.java // The student, starting version of the Lab10 assignment. import java.aut; import java.arrist."; public class Lab10vst extends Applet { public void paint (Graphics g) { drawSquare1 (g, 1024,768); } public void drawSquare1(Graphics g, int maxx, int maxX) { } int mid maxX/2; = maxX/2; int midy int stactwidth = maxX/4; int stactheight = maxX/4; int tlx = midx- (stantWidth/2): int tX midy. (startHeight/2); fillest (tlx.tlX.startwidth.startHeight); public void delay(long n) { } n* 1000; System.naneTime( long startRelax long endRelax = li while (endRelax - startRelax <n) System.paneTime(); endRelay = =
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education