From 1379f37646e10284447b46a2e60fb271172f9d2f Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Sat, 30 Sep 2023 17:28:33 +0200 Subject: [PATCH] Textet ne Sinuskurve oder so. V 0.1 --- sintest.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 sintest.py diff --git a/sintest.py b/sintest.py new file mode 100755 index 0000000..f796c54 --- /dev/null +++ b/sintest.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import os, sys, termios, tty, time, random +from math import sin, cos, sqrt +from time import sleep + + +termsize_xy = os.get_terminal_size() +xmax = termsize_xy[0] - 1 +ymax = termsize_xy[1] + +tree = "🌳" +frequency = int(xmax / 5) +street = tree +for i in range(0, frequency): + street += " " +street += tree +streetwidth = len(street) +amplitude = (xmax - streetwidth*4) / 3 +streetpos = amplitude +pi = 3.1416 +deg2rad = pi / 180 +toggle = 1 +maxpos = xmax - streetwidth +maxamp = xmax - streetwidth / 3 + + +def curpos(x, y): + print("\033[%d;%dH" % (y, x), end="", flush=True) + + +while True: + sleep(0.01) + amplitude += toggle + frequency = frequency + toggle + streetpos = int(sin(frequency * deg2rad) * cos(frequency * deg2rad + 1) * amplitude + streetwidth*4) + frequency += toggle + curpos(streetpos, ymax) + print(street) + if amplitude >= maxamp or amplitude < 3: + toggle *= -1 + + +sys.exit("Schulz nun.")