绘制算法
double coor[8];
int main() {
HDC hdc = GetHdc();
for (int i = 0; i < N; i++) {
for (int j = 0; j < 8; j++) {
coor[j] = coordinate[i][j];
}
double t = 0.0;
while (t <= 1.0) {
getInterPoint(4, t);
t = t + 0.0001;
SetPixel(hdc, ((coor[0]+0.6)/5+200), 200-coor[1]/5, RGB(255, 255, 255));
}
}
system("PAUSE");
}
void getInterPoint(int n,double t) {
if (n > 1) {
for (int i = 0; i < n - 1; i++) {
double x1 = coor[i*2 + 0];
double y1 = coor[i*2 + 1];
double x2 = coor[i*2 + 2];
double y2 = coor[i*2 + 3];
coor[i*2] = x1 + (x2 - x1)*t;
coor[i*2 + 1] = y1 + (y2 - y1)*t;
}
n--;
getInterPoint(n, t);
}
}
参数
double coordinate[16][8] = {
237,620,237,620,237,120,237,120,
237,120,237, 35,226, 24,143, 19,
143, 19,143, 19,143, 0,143, 0,
143, 0,143, 0,435, 0,435, 0,
435, 0,435, 0,435, 19,435, 19,
435, 19,353, 23,339, 36,339,109,
339,109,339,108,339,620,339,620,
339,620,339,620,393,620,393,620,
393,620,507,620,529,602,552,492,
552,492,552,492,576,492,576,492,
576,492,576,492,570,662,570,662,
570,662,570,662, 6,662, 6,662,
6,662, 6,662, 0,492, 0,492,
0,492, 0,492, 24,492, 24,492,
24,492, 48,602, 71,620,183,620,
183,620,183,620,237,620,237,620
};
int N = 16;
double coordinate[21][8] = {
289,452,289,452,166,452,166,452,
166,452,166,452,166,568,166,568,
166,568,166,627,185,657,223,657,
223,657,245,657,258,647,276,618,
276,618,292,589,304,580,321,580,
321,580,345,580,363,598,363,621,
363,621,363,657,319,683,259,683,
259,683,196,683,144,656,118,611,
118,611, 92,566, 84,530, 83,450,
83,450, 83,450, 1,450, 1,450,
1,450, 1,450, 1,418, 1,418,
1,418, 1,418, 83,418, 83,418,
83,418, 83,418, 83,104, 83,104,
83,104, 83, 31, 72, 19, 0, 15,
0, 15, 0, 15, 0, 0, 0, 0,
0, 0, 0, 0,260, 0,260, 0,
260, 0,260, 0,260, 15,260, 15,
260, 15,178, 18,167, 29,167,418,
167,104,167,104,167,418,167,418,
167,418,167,418,289,418,289,418,
289,418,289,418,289,452,289,452
};
int N = 21;
double coordinate[21][8] = {
149,597,149,597,149,597,345,597,
345,597,361,597,365,599,368,606,
368,606,406,695,358,606,406,695,
406,695,397,702,406,695,397,702,
397,702,382,681,372,676,351,676,
351,676,351,676,351,676,142,676,
142,676, 33,439,142,676, 33,439,
33,439, 32,438, 32,436, 32,434,
32,434, 32,438, 35,426, 44,426,
44,426, 74,426,109,420,149,408,
149,408,269,372,324,310,324,208,
324,208,324,112,264, 37,185, 37,
185, 37,165, 37,149, 44,119, 66,
119, 66, 86, 90, 65, 99, 42, 99,
42, 99, 14, 99, 0, 87, 0, 62,
0, 62, 0, 24, 46, 0,121, 0,
121, 0,205, 0,282, 27,333, 78,
333, 78,378,123,399,180,399,256,
399,256,399,327,381,372,333,422,
333,422,288,468,232,491,112,512,
112,512,112,512,149,597,149,597
};
int N = 21;