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
#!/usr/bin/python3 import turtle import time import os """ I couldnt make svg_turtle work, so I did some hacky bs instead anyway, we hide the turtle cursor, get the canvas, save the file then show the currsor again. this prevents the curror from appearing in the saved image This program saves the turtle canvas as an svg. and a post script file, (whatever rm it) as the current unix time. ep2svg is provided by the geg package """ # Draw something with the turtle turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) # Get the current Unix time current_time = int(time.time()) print("Current Unix time:", current_time) #hide the turtle for file write turtle.hideturtle() # Get the turtle canvas as a string canvas_data = turtle.getcanvas().postscript() # Construct the file name with the current time and the .ps extension ps_file_name = f"{current_time}.ps" svg_file_name = f"{current_time}.svg" # Write the canvas data to a PostScript file with open(ps_file_name, 'w') as f: f.write(canvas_data) # Show the turtle again turtle.showturtle() # Convert the PostScript file to SVG os.system('eps2svg ' + ps_file_name + ' ' + svg_file_name) # Close the turtle graphics window turtle.done()
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)