Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d9e62fb

Browse files
Sierpinski Carpet codes updated.
1 parent e279e87 commit d9e62fb

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

‎09-Fractal-Drawing/05-Sierpinski-Carpet/src/AlgoFrame.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import java.awt.Graphics2D;
2-
import java.awt.Graphics;
3-
import java.awt.Dimension;
4-
import java.awt.Color;
5-
import java.awt.RenderingHints;
1+
import java.awt.*;
62
import javax.swing.*;
73

84
public class AlgoFrame extends JFrame{
@@ -68,26 +64,26 @@ public void paintComponent(Graphics g) {
6864

6965
private void drawFractal(Graphics2D g, int x, int y, int w, int h, int depth){
7066

71-
int w_3 = w/3;
72-
int h_3 = h/3;
73-
74-
if(w_3 <= 0 || h_3 <= 0)
75-
return;
67+
int w_3 = w / 3;
68+
int h_3 = h / 3;
7669

7770
if( depth == data.depth ){
7871
AlgoVisHelper.setColor(g, AlgoVisHelper.Indigo);
79-
AlgoVisHelper.fillRectangle(g, x+w_3, y+h_3, w_3, h_3);
72+
AlgoVisHelper.fillRectangle(g, x + w_3, y + h_3, w_3, h_3);
8073
return;
8174
}
8275

76+
if(w <= 1 || h <= 1)
77+
return;
78+
8379
for(int i = 0 ; i < 3 ; i ++)
8480
for(int j = 0 ; j < 3 ; j ++)
8581
if(i == 1 && j == 1){
8682
AlgoVisHelper.setColor(g, AlgoVisHelper.Indigo);
87-
AlgoVisHelper.fillRectangle(g, x+i*w_3, y+j*h_3, w_3, h_3);
83+
AlgoVisHelper.fillRectangle(g, x + w_3, y + h_3, w_3, h_3);
8884
}
8985
else
90-
drawFractal(g, x+i*w_3, y+j*h_3, w_3, h_3, depth+1);
86+
drawFractal(g, x + i * w_3, y + j * h_3, w_3, h_3, depth + 1);
9187

9288
return;
9389
}

‎09-Fractal-Drawing/Chapter-09.key

182 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /