#!/usr/bin/python3 # -*- coding: utf-8 -*- import os, sys, termios, tty, time, random from math import sin, cos, sqrt from time import sleep # Randomly choose a cow cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕" cowslength = len(cows) cow = cows[random.randint(0, cowslength - 1)] # cow = "🐄" # cow = "*" if cow.isascii(): charlength = 1 else: charlength = 2 # Needed: find our screensize termsize_xy = os.get_terminal_size() # maximum and medium of points in a row xmax = termsize_xy[0] - 1 xmitte = xmax / 2 # maximum and medium of points in a column ymax = termsize_xy[1] ymitte = ymax / 2 # CTRL and ESC-codes for the used outputdevice. Probably a terminal. clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h" # pi is not defined by default. Noone has a display with 31416 Pixels in a row. U know better? Enhance it. pi = 3.1416 # This is for convenience, if you are thinking in degrees. It must not be recalculated every loop. deg2rad = pi / 180 # position cursor at x,y - where x=0 y=0 is the left lower corner like in mathematical diagrams # some scales, we need. Those UTF8Cows are 2 chars wide and need more space. So we have to scale one Axis radius = ymitte - 2 xradius = ymitte * charlength - 1 # Position the curser at x,y. Yes, we start with x, print does not, you are looking right. Leave it this way! def curpos(x, y): print("\033[%d;%dH" % (ymax - y, x), end="", flush=True) print(clear, curoff) # Draw a circle in maximum 360 Steps, one for for every degree for winkel in range(0, 359): x = sin(winkel * deg2rad) * xradius + xmitte y = cos(winkel * deg2rad) * radius + ymitte curpos(x, y) print(cow, end="") time.sleep(0.01) curpos(1, 1) sys.exit(curon + "Schulz nun.")