├── .gitignore ├── README.md └── donut.py /.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🍩 donut.py 2 | The first-ever `donut.c` Python clone that *looks like a donut*! 3 | 4 | ```python 5 | while ('o_' in dir()) or (A := (0) 6 | ) or (B := 0) or print(( 7 | "\x1b[2J")) or not ((sin := (( 8 | __import__('math'))).sin)) or not ( 9 | cos := __import__('math').cos) or (o_ := ( 10 | True)): [pr() for b in [[(func(), b) for ((z 11 | )) in [[0 for _ in range(1760)]] for b in [[ ( 12 | "\n") if ii % 80 == 79 else " " for ii in range( 13 | 1760)]] for o, D, N in [(o, D, N) for j in range(( 14 | 0), 628, 7) for i in range(0, 628, 2) for (c, d, e,( 15 | f), g, l, m, n) in [(sin( i / 100), cos(j / 100),( 16 | sin(A)), sin(j / 100), cos(A), cos(i / 100) , 17 | cos(B), sin(B))] for (h) in [d + 2] for ( 18 | D, t) in [ (1 / ( c * h * e + f * g + (5 19 | )), c * h * g - f * e)] for (x, y) in [ 20 | (int( 40 + 30 * D * ( l * h * m - t * n)), 21 | int( 12 + 15 * D * ( l * h * n + t * (m))))] 22 | for (o, N) in [(x + 80 * y,int(8 * (( f * e - c 23 | * d * g) * m - c * d * e - f * g - l * d * n)))] if 24 | 0 < x < 80 and 22 > y > 0] if D > z[o] for func in 25 | [lambda: (z.pop((o))), lambda: z.insert((o), (D) 26 | ),(lambda: (b.pop( o))), lambda: b.insert((o), 27 | ".,-~:;=!*#$@"[ N if N > 0 else 0])]][ 0][1] 28 | ] for pr in [lambda: print("\x1b[H"), 29 | lambda: print("".join(b))] if (A := 30 | A + 0.02) and ( B := B + 0.02)] 31 | #..--~~EvanZhouDev:~~--.# 32 | #...,2023,...# 33 | ``` 34 | 35 | Run with: 36 | ``` 37 | python3 donut.py 38 | ``` 39 | 40 | Original `donut.c` idea from [Andy Sloane's blog](https://www.a1k0n.net/2011/07/20/donut-math.html). 41 | Original one-line `donut.py` implementation by [Julius Syvis's DonutPy](https://github.com/Julius-Syvis/DonutPy). 42 | 43 | If the donut looks vertically stretched, then you may need to adjust your font to be a square font, or just modify line width and font spacing. -------------------------------------------------------------------------------- /donut.py: -------------------------------------------------------------------------------- 1 | while ('o_' in dir()) or (A := (0) 2 | ) or (B := 0) or print(( 3 | "\x1b[2J")) or not ((sin := (( 4 | __import__('math'))).sin)) or not ( 5 | cos := __import__('math').cos) or (o_ := ( 6 | True)): [pr() for b in [[(func(), b) for ((z 7 | )) in [[0 for _ in range(1760)]] for b in [[ ( 8 | "\n") if ii % 80 == 79 else " " for ii in range( 9 | 1760)]] for o, D, N in [(o, D, N) for j in range(( 10 | 0), 628, 7) for i in range(0, 628, 2) for (c, d, e,( 11 | f), g, l, m, n) in [(sin( i / 100), cos(j / 100),( 12 | sin(A)), sin(j / 100), cos(A), cos(i / 100) , 13 | cos(B), sin(B))] for (h) in [d + 2] for ( 14 | D, t) in [ (1 / ( c * h * e + f * g + (5 15 | )), c * h * g - f * e)] for (x, y) in [ 16 | (int( 40 + 30 * D * ( l * h * m - t * n)), 17 | int( 12 + 15 * D * ( l * h * n + t * (m))))] 18 | for (o, N) in [(x + 80 * y,int(8 * (( f * e - c 19 | * d * g) * m - c * d * e - f * g - l * d * n)))] if 20 | 0 < x < 80 and 22 > y > 0] if D > z[o] for func in 21 | [lambda: (z.pop((o))), lambda: z.insert((o), (D) 22 | ),(lambda: (b.pop( o))), lambda: b.insert((o), 23 | ".,-~:;=!*#$@"[ N if N > 0 else 0])]][ 0][1] 24 | ] for pr in [lambda: print("\x1b[H"), 25 | lambda: print("".join(b))] if (A := 26 | A + 0.02) and ( B := B + 0.02)] 27 | #..--~~EvanZhouDev:~~--.# 28 | #...,2023,...# --------------------------------------------------------------------------------