# [ipycc](https://ipy.cc)
> A Python package for creative coding in Jupyter
ipycc is a friendly tool for learning to code, making art, and exploring mathematics within [Jupyter](https://jupyter.org/) notebooks. Try it out at [https://code.ipy.cc](https://code.ipy.cc)!
The `Sketch` class provides a beginner-friendly API for drawing that is heavily inspired by [p5.js](https://p5js.org). `Sketch` lovingly borrows from p5.js' source code and documentation. Under the hood, it uses the powerful [ipycanvas](https://ipycanvas.readthedocs.io/en/latest/index.html) package for drawing.
The package also includes a (mostly) drop-in replacement for [Turtle graphics](https://docs.python.org/3/library/turtle.html) from the Python standard library. The `Turtle` class is based on the standard library's implementation and uses the `Sketch` class for rendering. ipycc bundles the standard library's `Vec2D` class for vector arithmetic along with a few helper functions.
ipycc runs smoothly in [JupyterLite](https://jupyterlite.readthedocs.io/en/stable/howto/index.html), creating a nice way to start coding without installing any software. [https://code.ipy.cc](https://code.ipy.cc) uses this setup.
## Installation
If you'd like to install ipycc locally, start by [downloading Python](https://www.python.org/downloads/). You can then create a virtual environment and install ipycc from your system shell like so:
On Unix/macOS:
```sh
mkdir ipycc
cd ipycc
python3 -m venv venv
source venv/bin/activate
pip install jupyterlab ipycc
```
On Windows:
```powershell
mkdir ipycc
cd ipycc
py -m venv venv
venv\Scripts\activate
pip install jupyterlab ipycc
```
The [Python Packaging User Guide](https://packaging.python.org/en/latest/tutorials/installing-packages/) has additional information to help you get up and running.
### 💡 Local alternatives
If you're running ipycc locally, you may also be interested in [py5](https://py5coding.org/) which uses [Processing](https://processing) for drawing. py5 has advanced features you may wish to explore at some point. ipycc mimics py5 where possible so that switching between the two is easy.
The standard library's version of Turtle graphics doesn't run in the web browser, but you can run it locally from Jupyter using the following [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-gui):
```python
from turtle import Turtle
%gui tk
t = Turtle()
t.forward(50) # opens in a separate window
```
## A tour of ipycc
Here are a few quick examples of ipycc in action.
### Sketches
A light gray square with a circle in its center. The circle is drawn with a white center and a black edge.
```python
from ipycc.sketch import Sketch
# Create the sketch and show it.
s = Sketch()
s.show()
# Paint the background.
s.background(200)
# Draw a circle.
s.circle(50, 50, 20)
```
A purple square with a circle in its center. The circle is drawn with a pink center and a thick white edge.
```python
from ipycc.sketch import Sketch
# Create the sketch and show it.
s = Sketch(400, 400)
s.show()
# Paint the background.
s.background("darkorchid")
# Style the circle.
s.stroke_weight(5)
s.stroke("ghostwhite")
s.fill("fuchsia")
# Draw the circle.
s.circle(200, 200, 100)
```
A purple square with a circle in its center. The circle is drawn with a pink center and a thick white edge. It moves slowly to the right and bounces off the wall.
```python
from time import sleep
from ipycanvas import hold_canvas
from ipycc.sketch import Sketch
# Create the sketch and show it.
s = Sketch(400, 400)
s.show()
# Initialize variables for position and speed.
x = 200
x_speed = 3
# Animate 100 frames.
for i in range(100):
# Send all drawing instructions for the frame at once.
with hold_canvas():
# Paint the background.
s.background("darkorchid")
# Update position.
x += x_speed
# Check for a collision and bounce.
if x > s.width:
x_speed = -3
# Style the circle.
s.stroke_weight(5)
s.stroke(248, 248, 255)
s.fill("#FF00FF")
# Draw the circle.
s.circle(x, 200, 100)
# Pause before drawing the next frame.
sleep(0.05)
```
### Turtles
A white square with a short black line extending from the center to the right. A black arrow tip at the end of the line points up.
```python
from ipycc.turtle import Turtle
# Create the turtle and show it.
t = Turtle()
t.show()
# Draw a line.
t.forward(50)
# Turn left.
t.left(90)
```
A white square with the outline of a smaller black square. The smaller square is drawn one side at a time.
```python
from ipycc.turtle import Turtle
# Create the turtle and show it.
t = Turtle()
t.show()
# Draw a square.
for i in range(4):
t.forward(50)
t.left(90)
```
A black square with a sprial pattern drawn in green. The spiral is drawn one side at a time.
```python
from ipycc.turtle import Turtle
# Create the turtle and show it.
t = Turtle()
t.show()
# Style the turtle.
t.bgcolor("black")
t.color(0, 1, 0)
# Draw a spiral.
for i in range(40):
length = i * 5
t.forward(length)
t.left(90)
```
## License
ipycc is licensed under the [GNU Lesser General Public License v3.0](https://choosealicense.com/licenses/lgpl-3.0/).
## Contributing
Found a bug or typo? Want a new feature? Feel free to open an issue in the project's [GitHub repository](https://github.com/nickmcintyre/ipycc)!
Raw data
{
"_id": null,
"home_page": null,
"name": "ipycc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.13",
"maintainer_email": null,
"keywords": "Art, Jupyter, Math, Sketch, Turtle, Visualization, p5.js",
"author": null,
"author_email": "Nick McIntyre <nick@mcintyre.io>",
"download_url": "https://files.pythonhosted.org/packages/53/7d/b5fb8d20498c127bdd219b61aa7210caf2358c9bb3454229163edb6b643c/ipycc-0.0.14.tar.gz",
"platform": null,
"description": "# [ipycc](https://ipy.cc)\n> A Python package for creative coding in Jupyter\n\nipycc is a friendly tool for learning to code, making art, and exploring mathematics within [Jupyter](https://jupyter.org/) notebooks. Try it out at [https://code.ipy.cc](https://code.ipy.cc)!\n\nThe `Sketch` class provides a beginner-friendly API for drawing that is heavily inspired by [p5.js](https://p5js.org). `Sketch` lovingly borrows from p5.js' source code and documentation. Under the hood, it uses the powerful [ipycanvas](https://ipycanvas.readthedocs.io/en/latest/index.html) package for drawing.\n\nThe package also includes a (mostly) drop-in replacement for [Turtle graphics](https://docs.python.org/3/library/turtle.html) from the Python standard library. The `Turtle` class is based on the standard library's implementation and uses the `Sketch` class for rendering. ipycc bundles the standard library's `Vec2D` class for vector arithmetic along with a few helper functions.\n\nipycc runs smoothly in [JupyterLite](https://jupyterlite.readthedocs.io/en/stable/howto/index.html), creating a nice way to start coding without installing any software. [https://code.ipy.cc](https://code.ipy.cc) uses this setup.\n\n## Installation\n\nIf you'd like to install ipycc locally, start by [downloading Python](https://www.python.org/downloads/). You can then create a virtual environment and install ipycc from your system shell like so:\n\nOn Unix/macOS:\n```sh\nmkdir ipycc\ncd ipycc\npython3 -m venv venv\nsource venv/bin/activate\npip install jupyterlab ipycc\n```\n\nOn Windows:\n```powershell\nmkdir ipycc\ncd ipycc\npy -m venv venv\nvenv\\Scripts\\activate\npip install jupyterlab ipycc\n```\n\nThe [Python Packaging User Guide](https://packaging.python.org/en/latest/tutorials/installing-packages/) has additional information to help you get up and running.\n\n### \ud83d\udca1 Local alternatives\n\nIf you're running ipycc locally, you may also be interested in [py5](https://py5coding.org/) which uses [Processing](https://processing) for drawing. py5 has advanced features you may wish to explore at some point. ipycc mimics py5 where possible so that switching between the two is easy.\n\nThe standard library's version of Turtle graphics doesn't run in the web browser, but you can run it locally from Jupyter using the following [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-gui):\n\n```python\nfrom turtle import Turtle\n\n%gui tk\n\nt = Turtle()\nt.forward(50) # opens in a separate window\n```\n\n## A tour of ipycc\n\nHere are a few quick examples of ipycc in action. \n\n### Sketches\n\nA light gray square with a circle in its center. The circle is drawn with a white center and a black edge.\n```python\nfrom ipycc.sketch import Sketch\n\n# Create the sketch and show it.\ns = Sketch()\ns.show()\n\n# Paint the background.\ns.background(200)\n\n# Draw a circle.\ns.circle(50, 50, 20)\n```\n\nA purple square with a circle in its center. The circle is drawn with a pink center and a thick white edge.\n```python\nfrom ipycc.sketch import Sketch\n\n# Create the sketch and show it.\ns = Sketch(400, 400)\ns.show()\n\n# Paint the background.\ns.background(\"darkorchid\")\n\n# Style the circle.\ns.stroke_weight(5)\ns.stroke(\"ghostwhite\")\ns.fill(\"fuchsia\")\n\n# Draw the circle.\ns.circle(200, 200, 100)\n```\n\nA purple square with a circle in its center. The circle is drawn with a pink center and a thick white edge. It moves slowly to the right and bounces off the wall.\n```python\nfrom time import sleep\nfrom ipycanvas import hold_canvas\nfrom ipycc.sketch import Sketch\n\n# Create the sketch and show it.\ns = Sketch(400, 400)\ns.show()\n\n# Initialize variables for position and speed.\nx = 200\nx_speed = 3\n\n# Animate 100 frames.\nfor i in range(100):\n # Send all drawing instructions for the frame at once.\n with hold_canvas():\n # Paint the background.\n s.background(\"darkorchid\")\n \n # Update position.\n x += x_speed\n \n # Check for a collision and bounce.\n if x > s.width:\n x_speed = -3\n \n # Style the circle.\n s.stroke_weight(5)\n s.stroke(248, 248, 255)\n s.fill(\"#FF00FF\")\n\n # Draw the circle.\n s.circle(x, 200, 100)\n\n # Pause before drawing the next frame.\n sleep(0.05)\n```\n\n### Turtles\n\nA white square with a short black line extending from the center to the right. A black arrow tip at the end of the line points up.\n```python\nfrom ipycc.turtle import Turtle\n\n# Create the turtle and show it.\nt = Turtle()\nt.show()\n\n# Draw a line.\nt.forward(50)\n# Turn left.\nt.left(90)\n```\n\nA white square with the outline of a smaller black square. The smaller square is drawn one side at a time.\n```python\nfrom ipycc.turtle import Turtle\n\n# Create the turtle and show it.\nt = Turtle()\nt.show()\n\n# Draw a square.\nfor i in range(4):\n t.forward(50)\n t.left(90)\n```\n\nA black square with a sprial pattern drawn in green. The spiral is drawn one side at a time.\n```python\nfrom ipycc.turtle import Turtle\n\n# Create the turtle and show it.\nt = Turtle()\nt.show()\n\n# Style the turtle.\nt.bgcolor(\"black\")\nt.color(0, 1, 0)\n\n# Draw a spiral.\nfor i in range(40):\n length = i * 5\n t.forward(length)\n t.left(90)\n```\n\n## License\n\nipycc is licensed under the [GNU Lesser General Public License v3.0](https://choosealicense.com/licenses/lgpl-3.0/).\n\n## Contributing\n\nFound a bug or typo? Want a new feature? Feel free to open an issue in the project's [GitHub repository](https://github.com/nickmcintyre/ipycc)!\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package for creative coding in Jupyter",
"version": "0.0.14",
"project_urls": {
"Homepage": "https://ipy.cc",
"Issues": "https://github.com/nickmcintyre/ipycc/issues"
},
"split_keywords": [
"art",
" jupyter",
" math",
" sketch",
" turtle",
" visualization",
" p5.js"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "269c0dc0c2c7a9f0a797e970ac10f99435fba9aa21e7dde7a054af24fb62bfe8",
"md5": "9948fdcf2258b32c26726630aaf7bfba",
"sha256": "79c0688e7d7acddf0283137c9ebbfccb12de9438135509e02ced760d3b1b9904"
},
"downloads": -1,
"filename": "ipycc-0.0.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9948fdcf2258b32c26726630aaf7bfba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.13",
"size": 31690,
"upload_time": "2025-09-07T03:15:43",
"upload_time_iso_8601": "2025-09-07T03:15:43.365330Z",
"url": "https://files.pythonhosted.org/packages/26/9c/0dc0c2c7a9f0a797e970ac10f99435fba9aa21e7dde7a054af24fb62bfe8/ipycc-0.0.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "537db5fb8d20498c127bdd219b61aa7210caf2358c9bb3454229163edb6b643c",
"md5": "676bee9187265d25a6ca1c83230318a4",
"sha256": "b8ae92671e3ce765d070dcd322ab6a21ece5df45feb5a5203baf54d4d5a29073"
},
"downloads": -1,
"filename": "ipycc-0.0.14.tar.gz",
"has_sig": false,
"md5_digest": "676bee9187265d25a6ca1c83230318a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.13",
"size": 40061,
"upload_time": "2025-09-07T03:15:44",
"upload_time_iso_8601": "2025-09-07T03:15:44.358963Z",
"url": "https://files.pythonhosted.org/packages/53/7d/b5fb8d20498c127bdd219b61aa7210caf2358c9bb3454229163edb6b643c/ipycc-0.0.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-07 03:15:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nickmcintyre",
"github_project": "ipycc",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ipycc"
}