Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
# tk_recaman.py from tkinter import * import math w = 1200 h = 600 span = 5 root = Tk() root.geometry("+0+0") frame = Frame(root) frame.pack(fill=BOTH, expand=True) h_scroll = Scrollbar(frame, orient=HORIZONTAL) h_scroll.pack(side=BOTTOM, fill=X) c = Canvas(frame, width=w, height=h, xscrollcommand=h_scroll.set, bg='white') c.pack(side=LEFT, fill=BOTH, expand=True) h_scroll.config(command=c.xview) used = {0} current = 0 n = 0 y = h // 2 cv_w = w def recaman(): global n, current, cv_w prev = current candidate = current - n if candidate > 0 and candidate not in used: current = candidate else: current = current + n used.add(current) r = abs(current - prev) * 2.5 x1 = min(prev, current) * span x2 = max(prev, current) * span s = 0 if n % 2: s = 180 c.create_arc(x1, y - r, x2, y + r, start=s, extent=180, style='arc') cv_w = max(cv_w, current * span) c.config(scrollregion=(0, 0, (cv_w), h)) n += 1 root.after(500, recaman) recaman() root.mainloop()
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)