Drawing

Hi,

Is it possible to draw circle, box and other basic shapes using shell scripts ?

If so can anyone please tell as how to do it.

Thanks in advance.

To my understanding if you are expecting to draw basic shapes on a "telnet" session then at most you can achieve is character based shapes. As telnet is a charater based application.

To draw character based shapes I dont think its going to be that difficult :slight_smile: though not as accurate you expect

It is possible to arbitrarily set the cursor to some position, then write from there. See the TERMCAP database and tput (man tput) how that works and which limitations this procedure has.

Hope this helps
bakunin

Just for fun...

awk -v X=12 -v Y=40 -v radius=12 'BEGIN{
  pi=3.142857
  system("tput clear")
  for(i=0 ;i<=359 ;i++){
    cmd=sprintf("tput cup %s %s", \
      int(.5 + X + (sin(i*pi/180)*radius)), \
      int(.5 + Y + (cos(i*pi/180)*radius)) )
    system(cmd)
    printf "*"
  }
  system("tput home")
}'

Not very circular...

                    *******
                 ****      ***
                **           **
               **             **
              **                *
             **                 **
            **                   **
            *                     *
            *                     *
           *                      **
           *                       *
           *                       *
           *                       *
           *                       *
           *                       *
           **                      *
            *                     *
            *                     *
            **                   **
             **                 **
              **               **
               **             **
                **           **
                 ***       ***
                    *******