Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "primlib.h"
- #include <stdlib.h>
- #include <math.h>
- #define ANGLE_OF_ROTATION M_PI/80
- #define VERTICLES 5
- #define VALUE_OF_DEALY 20
- void DrawPolygon (double origin_x, double origin_y , int radious, double rotation)
- {
- double start_x;
- double start_y;
- double stop_x;
- double stop_y;
- double polygonAngle = (2*M_PI)/ VERTICLES;
- int i;
- for (i = 0; i < VERTICLES; i++)
- {
- start_x = origin_x + radious * cos(polygonAngle* i + rotation);
- start_y = origin_y + radious * sin(polygonAngle* i + rotation);
- stop_x = origin_x + radious * cos(polygonAngle* (i + 1) + rotation);
- stop_y = origin_y + radious * sin(polygonAngle* (i + 1) + rotation);
- line(start_x, start_y, stop_x , stop_y, BLUE);
- }
- }
- int min (int a, int b)
- {
- if(a < b)
- return a;
- return b;
- }
- int main(int argc, char* argv[])
- {
- if(initGraph())
- {
- exit(3);
- }
- int radious = 10;
- int anlargment = 20;
- double rotation = 0 ;
- double origin_x = screenWidth() / 2;
- double origin_y = screenHeight() / 2;
- while(1)
- {
- filledRect(0, 0, screenWidth() - 1, screenHeight() - 1, BLACK);
- int maxRadious = (int)(min(screenWidth(), screenHeight())/2);
- anlargment = (anlargment + 1) % (2 * maxRadious);
- if (anlargment < maxRadious)
- {
- radious = anlargment;
- }
- else
- {
- radious = maxRadious - anlargment % maxRadious;
- }
- if (rotation + ANGLE_OF_ROTATION >= 2* M_PI)
- {
- rotation -= 2*M_PI;
- }
- rotation += ANGLE_OF_ROTATION;
- DrawPolygon( origin_x, origin_y , radious, rotation);
- updateScreen();
- SDL_Delay(VALUE_OF_DEALY);
- if (isKeyDown(SDLK_ESCAPE) == 1)
- {
- break;
- }
- }
- updateScreen();
- SDL_Delay(VALUE_OF_DEALY);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement