Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/ioctl.h>
- #include <iostream>
- #include <unistd.h>
- #include <cmath>
- void drawText(std::string text, int x, int y);
- void drawCircle(float width, float height, int x, int y, std::string character);
- int main(int argc, char **argv) {
- std::cout << "\ec" << "\e[0;0f";
- struct winsize w;
- ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
- drawCircle(15, 15, 20, 20, "+");
- std::cout << "\e[0;0f";
- return 0;
- }
- void drawText(std::string text, int x, int y) {
- if(x >= 0 && y >= 0)
- std::cout << "\e[" << y << ";" << x << "f" << text;
- }
- void drawCircle(float width, float height, int x, int y, std::string character) {
- for(int i = 0; i < 100; i++) {
- float angle = i * M_PI / 50;
- int xchar = round(x + width * cos(angle));
- int ychar = round(y + height * sin(angle));
- drawText(character, xchar, ychar);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement