Bezier曲线绘制算法与字母参数

版权声明:原创博文,若需转载,请与博主联系 https://blog.csdn.net/qq_38958113/article/details/82740306

绘制算法

//3次Bezier曲线的循环实现算法
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);
    }
}

参数

  • 字母T
double coordinate[16][8] = {
    //T: x1,y1,x2,y2,x3,y3,x4,y4 
    237,620,237,620,237,120,237,120, //1
    237,120,237, 35,226, 24,143, 19, //2
    143, 19,143, 19,143,  0,143,  0, //3
    143,  0,143,  0,435,  0,435,  0, //4
    435,  0,435,  0,435, 19,435, 19, //5
    435, 19,353, 23,339, 36,339,109, //6
    339,109,339,108,339,620,339,620, //7
    339,620,339,620,393,620,393,620, //8
    393,620,507,620,529,602,552,492, //9
    552,492,552,492,576,492,576,492, //10
    576,492,576,492,570,662,570,662, //11
    570,662,570,662,  6,662,  6,662, //12
      6,662,  6,662,  0,492,  0,492, //13
      0,492,  0,492, 24,492, 24,492, //14
     24,492, 48,602, 71,620,183,620, //15
    183,620,183,620,237,620,237,620  //16
};
int N = 16;

这里写图片描述

  • 字母f
double coordinate[21][8] = {
//F: x1,y1,x2,y2,x3,y3,x4,y4 
289,452,289,452,166,452,166,452, //1
166,452,166,452,166,568,166,568, //2
166,568,166,627,185,657,223,657, //3
223,657,245,657,258,647,276,618, //4
276,618,292,589,304,580,321,580, //5
321,580,345,580,363,598,363,621, //6
363,621,363,657,319,683,259,683, //7
259,683,196,683,144,656,118,611, //8
118,611, 92,566, 84,530, 83,450, //9
 83,450, 83,450,  1,450,  1,450, //10
  1,450,  1,450,  1,418,  1,418, //11
  1,418,  1,418, 83,418, 83,418, //12
 83,418, 83,418, 83,104, 83,104, //13
 83,104, 83, 31, 72, 19,  0, 15, //14
  0, 15,  0, 15,  0,  0,  0,  0, //15
  0,  0,  0,  0,260,  0,260,  0, //16
260,  0,260,  0,260, 15,260, 15, //17
260, 15,178, 18,167, 29,167,418, //18
167,104,167,104,167,418,167,418, //19
167,418,167,418,289,418,289,418, //20
289,418,289,418,289,452,289,452  //21
};
int N = 21;

这里写图片描述

  • 数字5
double coordinate[21][8] = {
    //5: x1,y1,x2,y2,x3,y3,x4,y4 
    149,597,149,597,149,597,345,597, //1
    345,597,361,597,365,599,368,606, //2
    368,606,406,695,358,606,406,695, //3
    406,695,397,702,406,695,397,702, //4
    397,702,382,681,372,676,351,676, //5
    351,676,351,676,351,676,142,676, //6
    142,676, 33,439,142,676, 33,439, //7
     33,439, 32,438, 32,436, 32,434, //8
     32,434, 32,438, 35,426, 44,426, //9
     44,426, 74,426,109,420,149,408, //10
    149,408,269,372,324,310,324,208, //11
    324,208,324,112,264, 37,185, 37, //12
    185, 37,165, 37,149, 44,119, 66, //13
    119, 66, 86, 90, 65, 99, 42, 99, //14
     42, 99, 14, 99,  0, 87,  0, 62, //15
      0, 62,  0, 24, 46,  0,121,  0, //16
    121,  0,205,  0,282, 27,333, 78, //17
    333, 78,378,123,399,180,399,256, //18
    399,256,399,327,381,372,333,422, //19
    333,422,288,468,232,491,112,512, //20
    112,512,112,512,149,597,149,597  //21
};
int N = 21;

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_38958113/article/details/82740306
今日推荐