Guest User

Untitled

a guest
Jan 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. /*
  2. Title: Bezier Curve
  3. Description: C Program to draw any kind of curve using Bezier Curve Algorithm
  4. Author: Saideep Dicholkar
  5. */
  6.  
  7. #include<stdio.h>
  8. #include<graphics.h>
  9. #include<math.h>
  10. void bezier(int x[4],int y[4]);
  11. void main()
  12. {
  13. int gd=DETECT,gm,i;
  14. int x[4],y[4];
  15. initgraph(&gd,&gm,"C:\\tc\\bgi");
  16. for(i=0;i<4;i++)
  17. {
  18. printf("\nEnter x y: ");
  19. scanf("%d%d",&x[i],&y[i]);
  20. }
  21. bezier(x,y);
  22. getch();
  23. closegraph();
  24. }
  25. void bezier(int x[4],int y[4])
  26. {
  27. double A,B,u;
  28. for(u=0.0;u<=1.0;u+=0.0005)
  29. {
  30. A=x[0]*pow((1-u),3)+x[1]*3*u*pow((1-u),2)+x[2]*3*pow(u,2)*(1-u)+x[3]*pow(u,3);
  31. B=y[0]*pow((1-u),3)+y[1]*3*u*pow((1-u),2)+y[2]*3*pow(u,2)*(1-u)+y[3]*pow(u,3);
  32. delay(1);
  33. putpixel(A,B,WHITE);
  34. }
  35. }
Add Comment
Please, Sign In to add comment