Sierpinski's Triangle is a simple and famous example of a fractal image. It is built recursively...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Sierpinski's Triangle is a simple and famous example of a fractal image. It is built recursively from a simple set of rules, illustrated in Figure 2. Your task will be to create an application that illustrates a perfect Sierpinski triangle, regardless of how large the application frame is. As the user moves and resizes the application window, the triangle should be redrawn and made larger or smaller as appropriate. Your program should display a frame that is based on the size of the user's screen. The paint Component method of the panel on which you are drawing will be called whenever the frame is resized, so that happens automagically and you don't have to worry about it. JPanels include a getHeight() and getWidth() method that you will be able to use to get the information you need for passing to a recursive draw function that you will write. The draw algorithm takes the coordinates and dimensions of a square area of the screen as input. If that square is the size of a single pixel, it should call drawRect() on the Graphics object passed into paint Component, drawing a one-pixel square at the given coordinates. If largerit should call the draw method three times recursively, once on the lower left quadrant of the square, once on the lower right, and once on an area centered above the other two (as illustrated in Figure 2). The solution will look a lot like Figure 3, with the largest triangle fitting into the largest square area of the frame, and the smallest triangles being three pixels in size. 0.00 Sierpinaki Triangles AAA Figure 3: Representative illustration of the Sierpinski problem solution. Sierpinski's Triangle is a simple and famous example of a fractal image. It is built recursively from a simple set of rules, illustrated in Figure 2. Your task will be to create an application that illustrates a perfect Sierpinski triangle, regardless of how large the application frame is. As the user moves and resizes the application window, the triangle should be redrawn and made larger or smaller as appropriate. Your program should display a frame that is based on the size of the user's screen. The paint Component method of the panel on which you are drawing will be called whenever the frame is resized, so that happens automagically and you don't have to worry about it. JPanels include a getHeight() and getWidth() method that you will be able to use to get the information you need for passing to a recursive draw function that you will write. The draw algorithm takes the coordinates and dimensions of a square area of the screen as input. If that square is the size of a single pixel, it should call drawRect() on the Graphics object passed into paint Component, drawing a one-pixel square at the given coordinates. If largerit should call the draw method three times recursively, once on the lower left quadrant of the square, once on the lower right, and once on an area centered above the other two (as illustrated in Figure 2). The solution will look a lot like Figure 3, with the largest triangle fitting into the largest square area of the frame, and the smallest triangles being three pixels in size. 0.00 Sierpinaki Triangles AAA Figure 3: Representative illustration of the Sierpinski problem solution.
Expert Answer:
Answer rating: 100% (QA)
package sierpinski import javaxswingJFrame import javaxswingJPanel import javaxswingWindowConstants import javaawtDimension import javaawtGraphics imp... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Janice Huffman has decided to start Jordan Cleaning, residential housecleaning service company. She is able to rent cleaning equipment at a cost of $780 per month. Labor costs are expected to be $60...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In Exercises 1 through 18, differentiate the given function. y = x x + 1 2
-
A centrifuge accelerates uniformly from rest to 15,000 rpm in 220s. Through how many revolutions did it turn in this time?
-
Consider the market for copper, where demand is given by the equation P(QD) = 500 - 1/2Q and market supply is given by P(Qs) = 50 Q. The discount rate is r=10% and there is a fixed supply of 400...
-
Refer to Problem 11.2. What are the standard errors of the regression coefficients for the model developed from the estimation data? How do they compare with the standard errors for the model in...
-
Calculating the Number of Periods Your Christmas ski vacation was great, but it unfortunately ran a bit over budget. All is not lost: You just received an offer in the mail to transfer your $10,000...
-
Joint Cost Allocation-Net Realizable Value Method Nature's Garden Inc. produces wood chips, wood pulp, and mulch. These products are produced through harvesting trees and sending the logs through a...
-
Letang Company has three divisions (R, S, and T), organized as decentralized profit centers. Division R produces the basic chemical Ranbax (in multiples of 1,000 pounds) and transfers it to Divisions...
-
Consider a SIM controlled by regulator X which activates downstream genes Zi, i= 1 .. n genes with thresholds Ki. At time t=0, X begins to be produced at a constant rate . (a) Are there biological...
-
Suppose we want to transmit the message 1011 0010 0100 1011 and protect it from errors using the CRC8 polynomial x 8 + x 2 + x 1 + 1. (a) Use polynomial long division to determine the message that...
-
What are your expectations when you join a new team?
-
How the duration of a sprint can be decided?
-
Which elements an agile software team must consider to attribute effort to a product?
-
Do you think the team members should work out their interpersonal differences on their own?
-
In a vegetable canning factory, canned food boxes containing 800 g of product are heat treated in an autoclave. Two food engineers working at the factory are planning to increase the production...
-
As indicated by mutual fund flows, investors tend to beat the market seek safety invest in last year's winner invest in last years loser
-
Write a GUI program for Programming Exercise 8.19, as shown in Figures 16.49ab. Let the user enter the numbers in the text fields in a grid of 6 rows and 7 columns. The user can click the Solve...
-
Write the following method that shuffles an ArrayList of numbers: public static void shuffle(ArrayList list)
-
Rewrite the servlet in Listing 37.4, GetParameters.java, using JSP. Create an HTML form that is identical to Student_Registration_Form. html in Listing 37.3 except that the action is replaced by...
-
An old-fashioned tire swing exerts a force on the branch and a torque about the point where the branch meets the trunk. If you hang the swing closer to the trunk, this will --the force and-- the...
-
Which of these objects is in static equilibrium? A. B. C. D.
-
A beam with a pivot on its le ft end is suspended from a rope. Tn which direction is the force of the pivot on the beam? A. B. C. D. E.
Study smarter with the SolutionInn App