C language drawing complex patterns

From , 5 Years ago, written in C, viewed 229 times.
URL https://pastebin.vip/view/6e5025cc
  1. #include "graphics.h"
  2. #include "math.h"
  3. #include "dos.h"
  4. #include "conio.h"
  5. #include "stdlib.h"
  6. #include "stdio.h"
  7. #include "stdarg.h"
  8. #define MAXPTS 15
  9. #define PI 3.1415926
  10. struct PTS
  11. {
  12.         int x,y;
  13. };
  14. double AspectRatio=0.85;
  15. void LineToDemo ( void )
  16. {
  17.         struct viewporttype vp;
  18.         struct PTS points[MAXPTS];
  19.         int i, j, h, w, xcenter, ycenter;
  20.         int radius, angle, step;
  21.         double rads;
  22.         printf ( " MoveTo / LineTo Demonstration" );
  23.         getviewsettings ( &vp );
  24.         h = vp.bottom - vp.top;
  25.         w = vp.right - vp.left;
  26.         xcenter = w / 2; /* Determine the center of circle */
  27.         ycenter = h / 2;
  28.         radius = ( h - 30 ) / ( AspectRatio * 2 );
  29.         step = 360 / MAXPTS; /* Determine # of increments */
  30.         angle = 0; /* Begin at zero degrees */
  31.         for ( i=0 ; irads = ( double ) angle * PI / 180.0; /* Convert angle to radians */
  32.                 points[i].x = xcenter + ( int ) ( cos ( rads ) * radius );
  33.                 points[i].y = ycenter - ( int ) ( sin ( rads ) * radius * AspectRatio );
  34.                 angle += step; /* Move to next increment */
  35.         }
  36.         circle ( xcenter, ycenter, radius ); /* Draw bounding circle */
  37. for ( i=0 ; ifor ( j=i ; jmoveto ( points[i].x, points[i].y ); /* Move to beginning of cord */
  38.                    lineto ( points[j].x, points[j].y ); /* Draw the cord */
  39.                    }
  40.                    }
  41.                    }
  42.                    main()
  43. {
  44. int driver,mode;
  45. driver=CGA;
  46. mode=CGAC0;
  47. initgraph ( &driver,&mode,"" );
  48.         setcolor ( 3 );
  49.         setbkcolor ( GREEN );
  50.         LineToDemo();
  51. }
  52.  

Reply to "C language drawing complex patterns"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website