-
Notifications
You must be signed in to change notification settings - Fork 28
/
example.pde
97 lines (78 loc) · 2.87 KB
/
example.pde
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Example {
public Frame frame;
public Layer layer;
public Example(Frame frame, Layer layer) {
this.frame = frame;
this.layer = layer;
}
}
Example example01() throws Exception {
PImage img = loadImage("ali.jpg");
WeaveConfig config = new WeaveConfig(3000, 0, 35, color(color(0, 0, 0), 25));
// crop to square
int min_length = img.width < img.height ? img.width : img.height;
img = img.get(0, 0, min_length, min_length);
// setup frame
frame = new CircleFrame(min_length/2, 256); // new SquareFrame(min_length, 256);
// scale it down... because bigger the frame, bigger number of threads required...
int cropped_size = 640;
if (cropped_size < min_length) {
min_length = cropped_size;
img.resize(min_length, min_length);
}
// setup layer
Layer layer = new MonochromeLayer(frame, img, config);
return new Example(frame, layer);
}
Example example02() throws Exception {
PImage img = loadImage("Lenna.jpg");
PImage[] imgs = {
loadImage("Lenna_Black.jpg"),
loadImage("Lenna_Blue.jpg"),
loadImage("Lenna_Yellow.jpg"),
loadImage("Lenna_Red.jpg"),
};
WeaveConfig[] configs = {
new WeaveConfig(2000, 0, 35, color(color(0, 0, 0), 25)),
new WeaveConfig(2000, 0, 35, color(color(13, 22, 189), 25)),
new WeaveConfig(1500, 0, 35, color(color(242, 229, 78), 25)),
new WeaveConfig(3000, 0, 35, color(color(181, 2, 2), 25)),
};
// crop to square
int min_length = img.width < img.height ? img.width : img.height;
img = img.get(0, 0, min_length, min_length);
// setup frame
frame = new CircleFrame(min_length/2, 256); // new SquareFrame(min_length, 256);
// scale it down... because bigger the frame, bigger number of threads required...
int cropped_size = 640;
if (cropped_size < min_length) {
min_length = cropped_size;
img.resize(min_length, min_length);
}
// setup layer
Layer layer = new MultipleImageLayer(frame, img, imgs, configs);
return new Example(frame, layer);
}
Example example03() throws Exception {
PImage img = loadImage("Lenna.jpg");
WeaveConfig[] configs = {
new WeaveConfig(2000, 0, 35, color(color(0, 0, 0), 25)),
new WeaveConfig(2000, 0, 35, color(color(13, 22, 189), 25)),
new WeaveConfig(1500, 0, 35, color(color(242, 229, 78), 25)),
new WeaveConfig(3000, 0, 35, color(color(181, 2, 2), 25)),
};
// crop to square
int min_length = img.width < img.height ? img.width : img.height;
img = img.get(0, 0, min_length, min_length);
// scale it down... because bigger the frame, bigger number of threads required...
int cropped_size = 640;
if (cropped_size < min_length) {
min_length = cropped_size;
img.resize(min_length, min_length);
}
// setup frame
frame = new CircleFrame(min_length/2, 256); // new SquareFrame(min_length, 256);
// setup layer
Layer layer = createColorLayer(frame, img, configs);
return new Example(frame, layer);
}