Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <graphics.h>
- #include <math.h>
- using namespace std;
- #define PI 3.14159265
- void drawHex(int lines, int radius, int *centerCoordinates, int color, bool filled = false, double angle = 0, bool isCircle = false)
- {
- int points[lines * 2]= {0};
- int n = lines, R = radius, Xc=(*centerCoordinates++), Yc=(*centerCoordinates);
- for(int i=0; i<n; i++)
- {
- double alfa = i * 2 * PI/n + angle;
- points[2*i] = Xc + R * cos(alfa);
- points[2*i+1] = Yc + R * sin(alfa);
- }
- points[lines * 2] = points[0];
- points[lines * 2 +1] = points[1];
- setcolor(color);
- if(filled)
- {
- fillpoly(lines+1,points);
- }
- drawpoly(lines+1,points);
- }
- int main()
- {
- initwindow(500, 250);
- setcolor(RED);
- int centerCoordinates[2] = {getmaxx()/2, getmaxy()/2};
- int i = 1, radius = 30;
- double a=0;
- while(true)
- {
- if(kbhit())
- {
- int c = getch();
- if (c == '+')
- a+=0.1;
- else if(c == '-' && radius != 0)
- {
- a-=0.1;
- }
- }
- drawHex(4, radius, centerCoordinates, RED, true, a, true);
- cleardevice();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement