Turtle graphics based on ipycanvas which can run on jupyter lab/vscode.
Project description
Demo
https://github.com/williamnavaraj/ipyturtle3/blob/main/Images/TurtleWin.gif
Example ipynb code. Run this in a cell.
import ipyturtle3 as turtle
from ipyturtle3 import hold_canvas
myCanvas=turtle.Canvas(width=500,height=250)
display(myCanvas)
myTS=turtle.TurtleScreen(myCanvas)
myTS.clear()
myTS.bgcolor("lightgreen")
bob=turtle.Turtle(myTS)
jess=turtle.Turtle(myTS,isHolonomic=True)
jess.shape("square")
bob.shape("turtle")
myTS.delay(200)
# Usual turtle Non-holonomic example
bob.forward(50)
bob.left(90)
bob.forward(50)
bob.left(90)
bob.forward(50)
bob.left(90)
bob.forward(50)
#Holonomic
jess.moveleft(200)
jess.moveup(100)
jess.moveright(100)
jess.movedown(100)
jess.turnright(45)
jess.turn(-45)
jess.distance_at_angle(50,45)
myTS.clear()
# Rainbow benzene
colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
t = turtle.Turtle(myTS)
myTS.bgcolor('black')
for x in range(50):
with(hold_canvas(myCanvas)):
t.pencolor(colors[x%6])
t.width(x//100 + 1)
t.forward(x)
t.left(59)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipyturtle3-0.1.0.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for ipyturtle3-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dba232104b62fd2740e9580aa3467246a5e9b131c3a454b909306fe39c1a2409 |
|
MD5 | 0a85eb012ba8d16691c6f8a162ccdf66 |
|
BLAKE2b-256 | aa2bfbcb43ea731f45bd67fae6b7003a4e65b14739af6aea72b169113af2870a |