Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. void Graf::drawing(sf::RenderWindow &window)
  2. {
  3.     //Points
  4.     sf::CircleShape shape(8.f);
  5.     shape.setFillColor(sf::Color(38, 37, 45, 250));
  6.     std::vector<std::pair<float, float>> vec(n);
  7.     for (int i = 0; i < n; i++)
  8.     {
  9.         vec[i].first = cos(i * 2 * 3.141592653589793238462643 / n)*R + x_zero;
  10.         vec[i].second = sin(i * 2 * 3.141592653589793238462643 / n)*R + y_zero;
  11.     }
  12.     //Number of points in text
  13.     sf::Font font;
  14.     font.loadFromFile("alligraph.ttf");
  15.     sf::Text text;
  16.     text.setFont(font);
  17.     text.setCharacterSize(30);
  18.     text.setColor(sf::Color::Red);
  19.     char str[11];
  20.     //Lines
  21.     sf::Vertex line[2];
  22.     //Draw
  23.     for (int i = 0; i < n; i++)
  24.     {
  25.         shape.setPosition(vec[i].first, vec[i].second);
  26.         window.draw(shape);
  27.     }
  28.     for (int i = 0; i < n; i++)
  29.         for (int k = 0; k < n; k++)
  30.         {
  31.             if (array[i][k])
  32.             {
  33.                 line[0] = sf::Vertex(sf::Vector2f(vec[i].first + 8, vec[i].second + 8));
  34.                 line[1] = sf::Vertex(sf::Vector2f(vec[k].first + 8, vec[k].second + 8));
  35.                 line[0].color = line[1].color = sf::Color(22, 26, 30, 250);
  36.                 window.draw(line, 2, sf::Lines);
  37.             }
  38.         }
  39.     for (int i = 0; i < n; i++)
  40.     {
  41.         int k = i + 1;
  42.         sprintf_s(str, "%d", k);
  43.         text.setString(str);
  44.         text.setPosition(vec[i].first + 4, vec[i].second + 2);
  45.         window.draw(text);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement