-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCraquelureMain.java
39 lines (33 loc) · 1.19 KB
/
CraquelureMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.Random;
import javax.swing.BorderFactory;
import javax.swing.border.BevelBorder;
public class CraquelureMain {
private static class ImagePanel extends JPanel {
private final Image img;
public ImagePanel(Image img) {
this.img = img;
this.setPreferredSize(new Dimension(img.getWidth(this), img.getHeight(this)));
this.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
}
public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, this);
}
}
public static void main(String[] args) {
JFrame f = new JFrame("Craquelure Demo");
f.setLayout(new GridLayout(1, 2));
BufferedImage img0 = Craquelure.createImage(new Random(12345), 750, 100, 0.03, 0.02);
f.add(new ImagePanel(img0));
BufferedImage img1 = Craquelure.createImage(new Random(12345), 750, 50, 0.1, 0.05);
f.add(new ImagePanel(img1));
f.pack();
f.setVisible(true);
}
}