{"id":20299850,"url":"https://github.com/python-ninja-hebi/ipyturtle-next","last_synced_at":"2025-10-09T02:20:50.278Z","repository":{"id":178032482,"uuid":"443802833","full_name":"Python-Ninja-Hebi/ipyturtle-next","owner":"Python-Ninja-Hebi","description":"Creating Turtle Graphics in IPython/Jupyter with ipycanvas","archived":false,"fork":false,"pushed_at":"2022-01-02T19:02:21.000Z","size":807,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-01T03:07:17.384Z","etag":null,"topics":["ipycanvas","jupyter","python","turtle"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Python-Ninja-Hebi.png","metadata":{"files":{"readme":"README.ipynb","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-02T15:39:16.000Z","updated_at":"2023-12-06T21:09:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"59a623db-2cb8-4f42-807f-20af58f44bcb","html_url":"https://github.com/Python-Ninja-Hebi/ipyturtle-next","commit_stats":null,"previous_names":["python-ninja-hebi/ipyturtle-next"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Python-Ninja-Hebi/ipyturtle-next","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fipyturtle-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fipyturtle-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fipyturtle-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fipyturtle-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Python-Ninja-Hebi","download_url":"https://codeload.github.com/Python-Ninja-Hebi/ipyturtle-next/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fipyturtle-next/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000782,"owners_count":26082906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipycanvas","jupyter","python","turtle"],"created_at":"2024-11-14T16:16:32.219Z","updated_at":"2025-10-09T02:20:50.258Z","avatar_url":"https://github.com/Python-Ninja-Hebi.png","language":"Python","readme":"{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# ipython-turtle-next\\n\",\n    \"## Creating Turtle Graphics in IPython/Jupyter with ipycanvas\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"This is inspired by https://github.com/gkvoelkl/ipython-turtle-widget. Thanks.  \\n\",\n    \"\\n\",\n    \"I am using **ipycanvas** (https://github.com/martinRenou/ipycanvas). Thanks to Martin Renou.\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"![](pic/screen.png)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"If you like it, use it. If you have some suggestions, tell me (hebi@python-ninja.com).\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Install\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### To install use pip:\"\n   ]\n  },\n  {\n   \"cell_type\": \"raw\",\n   \"metadata\": {},\n   \"source\": [\n    \"```\\n\",\n    \"$ pip install ipyturtlenext\\n\",\n    \"```\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Examples\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"The most examples are inspired by **Harold Abelson, Andrea diSessa: Turtle Geometry, MIT Press 1986**  \\n\",\n    \"\\n\",\n    \"**ipyturtlenext** should work in every jupyter environment, where ipycanvas works.\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Start\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"from ipyturtlenext import Turtle\\n\",\n    \"\\n\",\n    \"t = Turtle(width=200, height=200)\\n\",\n    \"t\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"With *width* and *height* you can change the extension of the drawing canvas.  \\n\",\n    \"\\n\",\n    \"In Jupyterlab you can create with *new view for outout* a separeted tab.\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### First Steps\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.right(90)\\n\",\n    \"t.heading()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.forward(150)\\n\",\n    \"t.left(45)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.back(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.left(45)\\n\",\n    \"t.penup()\\n\",\n    \"t.forward(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Square\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset() #clear canvas and start again\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.back(40)\\n\",\n    \"t.forward(100)\\n\",\n    \"t.position()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def square(size):\\n\",\n    \"    for i in range(4):\\n\",\n    \"        t.forward(size)\\n\",\n    \"        t.right(90)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"square(20)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Triangel\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def triangle(size):\\n\",\n    \"    for i in range(3):\\n\",\n    \"        t.forward(size)\\n\",\n    \"        t.right(120)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"triangle(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### House\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def house(size):\\n\",\n    \"    square(size)\\n\",\n    \"    t.forward(size)\\n\",\n    \"    t.right(30)\\n\",\n    \"    triangle(size)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.back(100)\\n\",\n    \"house(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Circle\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"\\n\",\n    \"def circle():\\n\",\n    \"    for i in range(360):\\n\",\n    \"        t.forward(1)\\n\",\n    \"        t.right(1)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"circle()\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Poly\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def poly(side, angle):\\n\",\n    \"    turn = 0\\n\",\n    \"    while turn == 0 or turn % 360 != 0:\\n\",\n    \"        t.forward(side)\\n\",\n    \"        t.right(angle)\\n\",\n    \"        turn += angle\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"poly(44,135)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Color\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Return the current pen color as RGB tuple or web color name\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"t.pencolor()\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Set pen color as web color name \"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.pencolor('Green')\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Set pen color with RGB value\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.pencolor(255,0,0)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.forward(40)\\n\",\n    \"t.right(120)\\n\",\n    \"t.pencolor('Blue')\\n\",\n    \"t.forward(40)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.pencolor('Red')\\n\",\n    \"t.pendown()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.forward(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Branch\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def lbranch(length, angle, level):\\n\",\n    \"    t.pencolor('Green')\\n\",\n    \"    t.forward(2*length)\\n\",\n    \"    node(length, angle, level)\\n\",\n    \"    t.back(2*length)\\n\",\n    \"    \\n\",\n    \"def rbranch(length, angle, level):\\n\",\n    \"    t.pencolor('Brown')\\n\",\n    \"    t.forward(length)\\n\",\n    \"    node(length, angle, level)\\n\",\n    \"    t.back(length)\\n\",\n    \"\\n\",\n    \"def node(length, angle, level):\\n\",\n    \"    if level==0:\\n\",\n    \"        return\\n\",\n    \"    t.left(angle)\\n\",\n    \"    lbranch(length, angle, level-1)\\n\",\n    \"    t.right(2*angle)\\n\",\n    \"    rbranch(length, angle, level-1)\\n\",\n    \"    t.left(angle)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"node(8,24,7)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Nested Triangle\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def nested_triangle(size):\\n\",\n    \"    if size \u003c 10:\\n\",\n    \"        return\\n\",\n    \"    for i in range(3):\\n\",\n    \"        nested_triangle(size/2)\\n\",\n    \"        t.forward(size)\\n\",\n    \"        t.right(120)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"nested_triangle(100)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Snowflake\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def snowflake(size, level):\\n\",\n    \"    for i in range(3):\\n\",\n    \"        side(size, level)\\n\",\n    \"        t.right(120)\\n\",\n    \"\\n\",\n    \"def side(size, level):\\n\",\n    \"    if level == 0:\\n\",\n    \"        t.forward(size)\\n\",\n    \"        return\\n\",\n    \"    side(size/3, level - 1)\\n\",\n    \"    t.left(60)\\n\",\n    \"    side(size/3, level - 1)\\n\",\n    \"    t.right(120)\\n\",\n    \"    side(size/3, level - 1)\\n\",\n    \"    t.left(60)\\n\",\n    \"    side(size/3, level - 1)\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"snowflake(100,4)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Nested squares\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"t.reset()\\n\",\n    \"sideLength = 40\\n\",\n    \"for square in range(5):\\n\",\n    \"    for side in range(4):\\n\",\n    \"        t.forward(sideLength)\\n\",\n    \"        t.left(90)\\n\",\n    \"    sideLength += 10\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Changelog\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"0.1.0 First published version  \"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": []\n  }\n ],\n \"metadata\": {\n  \"anaconda-cloud\": {},\n  \"kernelspec\": {\n   \"display_name\": \"Python 3 (ipykernel)\",\n   \"language\": \"python\",\n   \"name\": \"python3\"\n  },\n  \"language_info\": {\n   \"codemirror_mode\": {\n    \"name\": \"ipython\",\n    \"version\": 3\n   },\n   \"file_extension\": \".py\",\n   \"mimetype\": \"text/x-python\",\n   \"name\": \"python\",\n   \"nbconvert_exporter\": \"python\",\n   \"pygments_lexer\": \"ipython3\",\n   \"version\": \"3.9.7\"\n  },\n  \"widgets\": {\n   \"state\": {\n    \"9c8dc03f06b6421aac543dbcc7360258\": {\n     \"views\": [\n      {\n       \"cell_index\": 12\n      }\n     ]\n    }\n   },\n   \"version\": \"1.2.0\"\n  }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 4\n}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ninja-hebi%2Fipyturtle-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-ninja-hebi%2Fipyturtle-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ninja-hebi%2Fipyturtle-next/lists"}