Skip to content

Commit cd2c60f

Browse files
committed
Merge branch 'master' of https://github.com/mad4j/book-mdpc
2 parents 20f1dae + 592f516 commit cd2c60f

2 files changed

Lines changed: 56 additions & 51 deletions

File tree

examples/volume6-index.png

3.25 KB
Loading

examples/volume6/spectre/README.md

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,24 @@ final float Y1 = 999;
3434

3535

3636
final float[] HP = {
37-
481,0, 480,1, 473,1, 472,2, 459,4, 436,12, 419,21, 392,41,
38-
375,60, 361,81, 361,83, 355,93, 354,98, 352,102, 349,112, 347,119,
39-
346,121, 346,127, 345,128, 345,135, 344,166, 345,167, 345,174, 346,175,
40-
346,180, 347,181, 350,195, 354,208, 363,227, 372,240, 377,244, 394,268,
41-
405,281, 414,296, 418,306, 418,312, 419,313, 419,325, 418,326, 417,333,
42-
413,339, 405,346, 394,352, 388,353, 375,353, 373,352, 362,350, 344,341,
43-
299,311, 295,310, 272,295, 262,291, 260,289, 232,275, 226,274, 223,272,
44-
212,269, 204,268, 191,263, 179,261, 168,261, 167,260, 129,260, 128,261,
45-
114,262, 91,269, 67,281, 57,289, 44,301, 30,321, 19,340, 8,372,
46-
7,381, 3,392, 3,397, 2,398, 1,420, 0,422, 0,481, 1,482,
47-
1,493, 2,495, 2,502, 3,503, 3,510, 5,511, 7,531, 9,537,
48-
9,541, 10,542, 11,551, 14,555, 17,572, 22,584, 22,587, 27,604,
49-
32,613, 32,615, 50,654, 54,660, 60,666, 64,667, 66,666, 69,659,
50-
69,651, 68,649, 66,629, 65,628, 65,623, 64,622, 64,616, 62,615,
51-
62,610, 61,608, 61,603, 60,602, 60,595, 59,594, 57,566, 56,565,
52-
56,553, 54,552, 54,539, 53,538, 53,461, 54,460, 54,448, 56,447,
53-
57,429, 58,428, 58,423, 59,422, 61,409, 67,394, 76,378, 90,365,
54-
103,358, 111,358, 112,357, 126,358, 136,363, 145,371, 151,381, 152,391,
55-
153,392, 153,403, 152,404, 152,412, 151,413, 151,417, 149,424, 149,430,
56-
148,431, 148,440, 146,441, 146,450, 145,451, 145,465, 144,466, 144,517,
57-
145,518, 145,531, 146,532, 146,542, 148,543, 150,569, 152,575, 152,581,
58-
153,582, 154,593, 158,604, 159,614, 163,628, 163,633, 165,634, 167,646,
59-
169,651, 173,666, 175,670, 176,678, 181,688, 187,710, 192,719, 198,726,
60-
202,726, 208,721, 209,704, 208,703, 208,689, 207,688, 207,681, 205,680,
61-
205,674, 204,673, 204,662, 203,660, 202,637, 201,636, 201,618, 200,617,
62-
200,581, 199,580, 199,572, 200,571, 200,522, 201,521, 201,511, 202,510,
63-
205,476, 207,475, 207,469, 208,468, 209,459, 215,444, 221,431, 229,423,
64-
241,415, 247,413, 269,413, 285,419, 293,427, 297,434, 302,445, 302,449,
65-
304,456, 305,477, 304,478, 303,502, 302,503, 302,601, 303,602, 304,629,
66-
305,631, 305,638, 307,639, 307,646, 308,647, 308,655, 309,656, 310,668,
67-
311,669, 311,674, 312,675, 321,714, 328,733, 341,760, 345,763, 350,763,
68-
354,758, 353,728, 352,727, 350,690, 349,689, 349,612, 350,611, 350,593,
69-
351,592, 351,579, 352,577, 353,559, 354,558, 354,550, 355,549, 355,539,
70-
356,538, 356,531, 358,530, 358,525, 361,517, 361,513, 369,497, 377,487,
71-
388,478, 397,475, 413,475, 414,476, 422,477, 431,481, 443,491, 448,499,
72-
455,512, 459,527, 460,528, 460,531, 461,532, 463,549, 464,550, 464,556,
73-
465,558, 467,582, 468,583, 468,594, 469,595, 469,608, 470,610, 470,627,
74-
471,628, 471,646, 472,647, 472,664, 473,665, 473,680, 475,681, 476,715,
75-
477,716, 478,761, 479,762, 479,780, 480,781, 481,815, 482,816, 485,886,
76-
486,887, 486,904, 487,905, 487,916, 488,917, 488,935, 489,936, 489,955,
77-
490,956, 492,991, 494,997, 496,999, 503,999, 507,993, 509,968, 510,967,
78-
512,917
37+
481,0, 473,1, 459,4, 419,21, 375,60, 361,83, 354,98, 346,121,
38+
345,128, 344,166, 346,180, 350,195, 363,227, 377,244, 405,281, 418,306,
39+
419,313, 418,326, 413,339, 394,352, 375,353, 362,350, 299,311, 272,295,
40+
260,289, 226,274, 212,269, 191,263, 168,261, 129,260, 114,262, 67,281,
41+
44,301, 19,340, 7,381, 3,397, 1,420, 0,481, 1,493, 3,510,
42+
11,551, 17,572, 22,587, 32,613, 50,654, 60,666, 66,666, 69,651,
43+
64,616, 62,610, 61,603, 57,566, 56,553, 54,539, 53,461, 54,448,
44+
58,423, 61,409, 76,378, 103,358, 112,357, 136,363, 151,381, 153,392,
45+
152,404, 151,413, 149,424, 148,431, 146,441, 145,451, 144,466, 145,518,
46+
146,532, 148,543, 153,582, 158,604, 163,628, 165,634, 169,651, 175,670,
47+
181,688, 192,719, 202,726, 209,704, 208,689, 207,681, 205,674, 202,637,
48+
201,618, 200,581, 199,572, 200,522, 201,511, 205,476, 207,469, 209,459,
49+
221,431, 241,415, 269,413, 293,427, 302,445, 304,456, 304,478, 302,503,
50+
303,602, 305,631, 307,639, 309,656, 312,675, 328,733, 345,763, 354,758,
51+
352,727, 349,689, 350,611, 352,577, 356,538, 361,517, 369,497, 388,478,
52+
413,475, 422,477, 443,491, 455,512, 460,528, 461,532, 464,550, 468,583,
53+
470,610, 473,665, 475,681, 477,716, 480,781, 487,905, 488,917, 490,956,
54+
494,997, 503,999, 509,968, 512,917
7955
};
8056

8157

@@ -95,18 +71,47 @@ void draw() {
9571
scale(s);
9672
fill(INK);
9773
noStroke();
98-
74+
75+
drawContour();
76+
77+
save("spectre.png");
78+
}
79+
80+
81+
int contourCount() {
82+
return HP.length;
83+
}
84+
85+
86+
PVector contourPoint(int idx) {
87+
int n = HP.length / 2;
88+
89+
if (idx < n) {
90+
return new PVector(HP[2 * idx], HP[2 * idx + 1]);
91+
}
92+
93+
int j = 2 * n - 1 - idx;
94+
return new PVector(2 * AXIS - HP[2 * j], HP[2 * j + 1]);
95+
}
96+
97+
98+
void drawContour() {
99+
int count = contourCount();
100+
99101
beginShape();
100-
for(int i=0; i<HP.length; i+=2) {
101-
vertex(HP[i], HP[i+1]);
102-
}
103-
104-
for(int i=HP.length-2; i>=0; i-=2) {
105-
vertex(2*AXIS-HP[i], HP[i+1]);
102+
PVector pLast = contourPoint(count - 1);
103+
curveVertex(pLast.x, pLast.y);
104+
105+
for (int i = 0; i < count; i++) {
106+
PVector p = contourPoint(i);
107+
curveVertex(p.x, p.y);
106108
}
107-
endShape(CLOSE);
108109

109-
save("spectre.png");
110+
PVector p0 = contourPoint(0);
111+
PVector p1 = contourPoint(1);
112+
curveVertex(p0.x, p0.y);
113+
curveVertex(p1.x, p1.y);
114+
endShape(CLOSE);
110115
}
111116

112117
```

0 commit comments

Comments
 (0)