Advertisement
Guest User

Untitled

a guest
May 29th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <sys/ioctl.h>
  2. #include <iostream>
  3. #include <unistd.h>
  4. #include <cmath>
  5.  
  6. void drawText(std::string text, int x, int y);
  7. void drawCircle(float width, float height, int x, int y, std::string character);
  8.  
  9. int main(int argc, char **argv) {
  10.   std::cout << "\ec" << "\e[0;0f";
  11.   struct winsize w;
  12.   ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
  13.  
  14.   drawCircle(15, 15, 20, 20, "+");
  15.  
  16.   std::cout << "\e[0;0f";
  17.   return 0;
  18. }
  19.  
  20. void drawText(std::string text, int x, int y) {
  21.   if(x >= 0 && y >= 0)
  22.     std::cout << "\e[" << y << ";" << x << "f" << text;
  23. }
  24.  
  25. void drawCircle(float width, float height, int x, int y, std::string character) {
  26.   for(int i = 0; i < 100; i++) {
  27.     float angle = i * M_PI / 50;
  28.     int xchar = round(x + width  * cos(angle));
  29.     int ychar = round(y + height * sin(angle));
  30.     drawText(character, xchar, ychar);
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement