Creating Turtle Geometry in IPython (Jupyter Widget)
Project description
Creating Turtle Graphics in IPython/Jupyter
Draw on the page or use an extra window. under construction
If you like it, use it. If you have some suggestions, tell me (gkvoelkl@nelson-games.de).
Install
To install use pip:
` $ pip install ipyturtle $ jupyter nbextension enable --py --sys-prefix ipyturtle `
For a development installation (requires npm),
` $ git clone https://github.com/gkvoelkl/ipython-turtle-widget.git $ cd ipython-turtle-widget $ pip install -e . $ jupyter nbextension install --py --symlink --sys-prefix ipyturtle $ jupyter nbextension enable --py --sys-prefix ipyturtle `
Examples
The most examples are inspired by Harold Abelson, Andrea diSessa: Turtle Geometry, MIT Press 1986
Start
from ipyturtle import Turtle
t = Turtle()
t
Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"
The turtle is drawn on its own part of the screen.
Or integrate the turtle graphic into the page
t2 = Turtle(fixed=False, width=100, height=100)
t2
With width and height you can change the extension of the drawing canvas.
First Steps
t.back(40)
t.forward(100)
t.position()
(0.0, 60.0)
t.right(90)
t.heading()
0
t.forward(150)
t.left(45)
t.back(100)
t.left(45)
t.penup()
t.forward(100)
Square
t.reset() #clear canvas and start again
def square(size):
for i in range(4):
t.forward(size)
t.right(90)
square(20)
Triangel
t.reset()
def triangle():
for i in range(3):
t.forward(100)
t.right(120)
triangle()
Circle
t = Turtle(fixed=False, width=120, height=120)
def circle():
for i in range(360):
t.forward(1)
t.right(1)
t
circle()
Changelog
0.2.0 First published version
Sources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for ipyturtle-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e14b4693e4c538f09f2b4ee3e98c8aba492bbf008be2732022e2ff470d6f187 |
|
MD5 | 071430edcdac204471a368fc023f5547 |
|
BLAKE2b-256 | a0eb6634ea1e2d6df4415a7a6e279bb5e989d278d390656e1ff08bc0bb47e9d9 |