0

hello everybody

I am writing a program in java that draws a square fractal recursively. The program starts by drawing a rectangle in the center of the window (1/4 of the window). Then I need to draw 4 smaller rectangles attached to the corners of the first rectangle. Then I need to draw 3 smaller rectangles attached to the corners to the corners of the previous rectangle and so on until it reaches to 1 pixel. Each one of the succeeding rectangles is half the width and height or the preceding rectangle. The output should be like this picture

Untitled28

I am new to computer science so please help even with a pseudo code that can explain the steps and calculations to draw the rectangles.

thank you in advance

Edited by MahdiAlQaffas

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by NormR1
0

Take a piece of grid paper and draw out the first set of rectangles and look at the relationship between the x,y for the large rectangle and the smaller ones at each corner. Then draw the next set and do the same to find the formula for computing the x,y for all the rectangles.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.