Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- transform(hdc);
- SelectObject(hdc, hBezier);
- for (i = 1; i< count-1; i++) {
- int xA = pt[i-1].x;
- int xB = pt[i].x;
- int xC = pt[i+1].x;
- int xD = pt[i+2].x;
- int yA = pt[i-1].y;
- int yB = pt[i].y;
- int yC = pt[i+1].y;
- int yD = pt[i+2].y;
- double a3 = (-xA+3*(xB-xC)+xD)/6.0;
- double b3 = (-yA+3*(yB-yC)+yD)/6.0;
- double a2 = (xA-2*xB+xC)/2.0;
- double b2 = (yA-2*yB+yC)/2.0;
- double a1 = (xC-xA)/2.0;
- double b1 = (yC-yA)/2.0;
- double a0 = (xA+4*xB+xC)/6.0;
- double b0 = (yA+4*yB+yC)/6.0;
- for (j = 0; j <= count; j++) {
- double t = (float)j/(float)count;
- double X = ((a3*t+a2)*t+a1)*t+a0;
- double Y = ((b3*t+b2)*t+b1)*t+b0;
- double first = 0;
- if (i==1 && j==0) {
- LPPOINT lppt = LPPOINT();
- MoveToEx(hdc, X, Y, lppt);
- }
- LineTo(hdc, X, Y);
- }
- }
- for (i = 0; i < count; i++) {
- SetRect(&rt, pt[i].x - MARK, pt[i].y - MARK, pt[i].x + MARK, pt[i].y + MARK);
- FillRect(hdc, &rt, hRect);
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement