Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. case WM_PAINT:
  2. hdc = BeginPaint(hWnd, &ps);
  3. transform(hdc);
  4.  
  5.  
  6. SelectObject(hdc, hBezier);
  7.  
  8. for (i = 1; i< count-1; i++) {
  9. int xA = pt[i-1].x;
  10. int xB = pt[i].x;
  11. int xC = pt[i+1].x;
  12. int xD = pt[i+2].x;
  13.  
  14. int yA = pt[i-1].y;
  15. int yB = pt[i].y;
  16. int yC = pt[i+1].y;
  17. int yD = pt[i+2].y;
  18.  
  19. double a3 = (-xA+3*(xB-xC)+xD)/6.0;
  20. double b3 = (-yA+3*(yB-yC)+yD)/6.0;
  21.  
  22. double a2 = (xA-2*xB+xC)/2.0;
  23. double b2 = (yA-2*yB+yC)/2.0;
  24.  
  25. double a1 = (xC-xA)/2.0;
  26. double b1 = (yC-yA)/2.0;
  27.  
  28. double a0 = (xA+4*xB+xC)/6.0;
  29. double b0 = (yA+4*yB+yC)/6.0;
  30.  
  31. for (j = 0; j <= count; j++) {
  32. double t = (float)j/(float)count;
  33. double X = ((a3*t+a2)*t+a1)*t+a0;
  34. double Y = ((b3*t+b2)*t+b1)*t+b0;
  35. double first = 0;
  36. if (i==1 && j==0) {
  37. LPPOINT lppt = LPPOINT();
  38. MoveToEx(hdc, X, Y, lppt);
  39. }
  40. LineTo(hdc, X, Y);
  41. }
  42. }
  43.  
  44. for (i = 0; i < count; i++) {
  45. SetRect(&rt, pt[i].x - MARK, pt[i].y - MARK, pt[i].x + MARK, pt[i].y + MARK);
  46. FillRect(hdc, &rt, hRect);
  47. }
  48. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement