SHARE
TWEET

Untitled

a guest Jan 20th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <graphics.h>
  3. #include <math.h>
  4. #include <fstream>
  5. #define PI 3.1415
  6. #define N 12
  7. #define R 80
  8.  
  9. int poligon[2*N+2];
  10. int poligon2[2*N+2];
  11. int poligon3[3*N+2];
  12.  
  13. using namespace std;
  14.  
  15. void waitForLeftMouseClick();
  16.  
  17. void generarePCTE3()  ///genereaza punctele poligonului
  18. {
  19.     double alfa = 2*PI/N;
  20.     for(int i=0; i<N+1; i++)
  21.     {
  22.         poligon3[2*i]   = R*cos(i*alfa)+250; ///coordonte x
  23.         poligon3[2*i+1] = R*sin(i*alfa);  /// coordonate y
  24.     }
  25.  
  26. }
  27.  
  28. void generarePCTE()  ///genereaza punctele poligonului
  29. {
  30.     double alfa = 2*PI/N;
  31.     for(int i=0; i<N+1; i++)
  32.     {
  33.         poligon[2*i]   = R*cos(i*alfa); ///coordonte x
  34.         poligon[2*i+1] = R*sin(i*alfa);  /// coordonate y
  35.     }
  36. }
  37. void generarePCTE2()  ///genereaza punctele poligomului scalat cu 2.5
  38. {
  39.     double alfa = 2*PI/N;
  40.     for(int i=0; i<N+1; i++)
  41.     {
  42.         poligon2[2*i]   = R*2.5*cos(i*alfa); ///coordonate x
  43.         poligon2[2*i+1] = R*2.5*sin(i*alfa);  /// coordonate y
  44.     }
  45. }
  46.  
  47. void translatie(int points[], int tx, int ty)    ///se face translatia
  48. {
  49.     for(int i=0; i<N+1; i++)
  50.     {
  51.         points[2*i] = points[2*i] + tx;
  52.         points[2*i+1]= points[2*i+1] + ty;
  53.     }
  54. }
  55. int main()
  56. {
  57.     initwindow(1100,1100);
  58.     setlinestyle(SOLID_LINE, 0,2);
  59.     setcolor(RED);
  60.     generarePCTE();
  61.     generarePCTE2();
  62.     translatie(poligon,420,250);
  63.     drawpoly(13,poligon);
  64.     delay(200);
  65.     translatie(poligon2,420,250);
  66. drawpoly(13,poligon2);
  67. delay(200);
  68. //generarePCTE3();
  69. //setcolor(YELLOW);
  70. //drawpoly(13,poligon3);
  71. setcolor(2);
  72.  waitForLeftMouseClick();
  73.  cleardevice();
  74. ///B0 –A0 –A1 –B1 –B2 –A2 –A3 –B3 .. etc(2p
  75. moveto(poligon2[0],poligon2[1]);
  76.  lineto(poligon[0],poligon[1]);
  77.  delay(30);
  78.  lineto(poligon[2],poligon[3]);
  79.  lineto(poligon2[2],poligon2[3]);
  80.  delay(30);
  81.  lineto(poligon2[4],poligon2[5]);
  82.  lineto(poligon[4],poligon[5]);
  83.  delay(30);
  84.  lineto(poligon[6],poligon[7]);
  85.  lineto(poligon2[6],poligon2[7]);
  86.  delay(30);
  87.  lineto(poligon2[8],poligon2[9]);
  88.  lineto(poligon[8],poligon[9]);
  89.  delay(30);
  90.  lineto(poligon[10],poligon[11]);
  91.  lineto(poligon2[10],poligon2[11]);
  92.  delay(30);
  93.  lineto(poligon2[12],poligon2[13]);
  94.  lineto(poligon[12],poligon[13]);
  95.  delay(30);
  96.  lineto(poligon[14],poligon[15]);
  97.  lineto(poligon2[14],poligon2[15]);
  98.  delay(30);
  99.  lineto(poligon2[16],poligon2[17]);
  100.  lineto(poligon[16],poligon[17]);
  101.  delay(30);
  102.  lineto(poligon[18],poligon[19]);
  103.  lineto(poligon2[18],poligon2[19]);
  104.  delay(30);
  105.  lineto(poligon2[20],poligon2[21]);
  106.  lineto(poligon[20],poligon[21]);
  107.  delay(30);
  108.  lineto(poligon[22],poligon[23]);
  109.  lineto(poligon2[22],poligon2[23]);
  110.  delay(30);
  111.  lineto(poligon2[24],poligon2[25]);
  112.     waitForLeftMouseClick();
  113. // moveto()
  114.  
  115. /*for(int i=0;i<12;i++)
  116. {
  117.     lineto(poligon[k],poligon[k+1]);
  118.     lineto(poligon[k+2],poligon[k+3]);
  119.     k++;
  120. } */
  121.  
  122.  
  123.    // waitForLeftMouseClick();
  124.     cleardevice();
  125.     generarePCTE3();
  126.    // translatie(poligon3,420,250);
  127.     drawpoly(13,poligon3);
  128.  
  129.  
  130.  
  131.     waitForLeftMouseClick();
  132. }
  133.  
  134. void waitForLeftMouseClick()
  135. {
  136.     clearmouseclick(WM_LBUTTONDOWN);
  137.     const int DELAY = 50; // Milliseconds of delay between checks
  138.     int x, y;
  139.     while (!ismouseclick(WM_LBUTTONDOWN))
  140.         delay(DELAY);
  141.     getmouseclick(WM_LBUTTONDOWN, x, y);
  142. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top