很奇妙的分形图,佩服作者的想象力,我是在理解的基础上借鉴,Button做的很烂,呵呵!
很喜欢递归算法,我一定要原创一个给你们看看!
//KochSnowflake.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class KochSnowflake extends JApplet implements ActionListener {
private final int APPLET_WIDTH = 400;
private final int APPLET_HEIGHT = 440;
private final int MIN = 1, MAX = 9;
private JButton increase,decrease;
private JLabel titleLabel,orderLabel;
private KochPanel drawing;
private JPanel appletPanel,tools;
public void init() {
tools = new JPanel();
tools.setLayout(new BoxLayout(tools,BoxLayout.X_AXIS));
tools.setBackground(Color.yellow);
tools.setOpaque(true);
titleLabel = new JLabel("the koch snowflake");
titleLabel.setForeground(Color.black);
increase = new JButton("increase.gif");
increase.setPressedIcon(new ImageIcon("increasePressed.gif"));
increase.setMargin(new Insets(0,0,0,0));
&n

本文介绍了一种使用递归算法绘制Koch雪花分形图的方法,展示了作者对递归算法的热爱。通过Java Swing实现了一个简单的JApplet,允许用户调整分形的复杂度。代码中详细解释了如何绘制分形,并提供了关键类`KochSnowflake`和`KochPanel`的实现。
最低0.47元/天 解锁文章
963

被折叠的 条评论
为什么被折叠?



