Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Graf::drawing(sf::RenderWindow &window)
- {
- //Points
- sf::CircleShape shape(8.f);
- shape.setFillColor(sf::Color(38, 37, 45, 250));
- std::vector<std::pair<float, float>> vec(n);
- for (int i = 0; i < n; i++)
- {
- vec[i].first = cos(i * 2 * 3.141592653589793238462643 / n)*R + x_zero;
- vec[i].second = sin(i * 2 * 3.141592653589793238462643 / n)*R + y_zero;
- }
- //Number of points in text
- sf::Font font;
- font.loadFromFile("alligraph.ttf");
- sf::Text text;
- text.setFont(font);
- text.setCharacterSize(30);
- text.setColor(sf::Color::Red);
- char str[11];
- //Lines
- sf::Vertex line[2];
- //Draw
- for (int i = 0; i < n; i++)
- {
- shape.setPosition(vec[i].first, vec[i].second);
- window.draw(shape);
- }
- for (int i = 0; i < n; i++)
- for (int k = 0; k < n; k++)
- {
- if (array[i][k])
- {
- line[0] = sf::Vertex(sf::Vector2f(vec[i].first + 8, vec[i].second + 8));
- line[1] = sf::Vertex(sf::Vector2f(vec[k].first + 8, vec[k].second + 8));
- line[0].color = line[1].color = sf::Color(22, 26, 30, 250);
- window.draw(line, 2, sf::Lines);
- }
- }
- for (int i = 0; i < n; i++)
- {
- int k = i + 1;
- sprintf_s(str, "%d", k);
- text.setString(str);
- text.setPosition(vec[i].first + 4, vec[i].second + 2);
- window.draw(text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement