Advertisement
paperline27

circle.sh

Dec 4th, 2024
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.89 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Konfigurasi lingkaran                                               radius=10      # Radius lingkaran
  4. scale=2        # Skala horizontal untuk memperbaiki rasio aspek
  5.  
  6. # Loop menggambar lingkaran
  7. for ((y = radius; y >= -radius; y--)); do
  8.     for ((x = -radius * scale; x <= radius * scale; x++)); do                 # Hitung jarak titik (x, y) dari pusat (0, 0)
  9.         distance=$(echo "sqrt(($x / $scale)^2 + $y^2)" | bc -l)
  10.  
  11.         # Variasikan karakter berdasarkan jarak dari radius
  12.         if (( $(echo "$distance <= $radius + 0.3 && $distance >= $rad>
  13.            echo -n "#"
  14.         elif (( $(echo "$distance <= $radius + 0.6 && $distance > $ra>
  15.            echo -n "="
  16.        elif (( $(echo "$distance >= $radius - 0.6 && $distance < $ra>
  17.             echo -n "="
  18.         else
  19.             echo -n " "
  20.         fi
  21.     done
  22.     echo # Pindah ke baris berikutnya
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement