Joy is a tiny creative coding library in Python.

Related tags

IDEjoy
Overview

Joy

Joy is a tiny creative coding library in Python.

Installation

The easiest way to install it is download joy.py and place it in your directory. The library has no dependencies.

It can be downloaded from:

https://github.com/fossunited/joy/raw/main/joy.py

Coordinate System

Joy uses a canvas with (0, 0) as the center of the canvas.

By default, the size of the canvas is (300, 300).

Using Joy

The Joy library integrates well with Jupyter environment and it is recommended to explore Joy in a Jupyter lab.

The first thing you need to do is import the module.

from joy import *

Once the functionality in the module is imported, you can start playing with it.

Basic Shapes

Joy supports the basic shapes circle, ellipse, rectangle and line.

Let's start with a drawing a circle:

c = circle()
show(c)

svg

By default circle will have center at (0, 0) and radius as 100. But you can specify different values.

c = circle(x=50, y=50, r=50)
show(c)

svg

The other basic types that are supported are ellipse, rectangle, and line:

s1 = circle()
s2 = ellipse()
s3 = rectangle()
s4 = line()
show(s1, s2, s3, s4)

svg

Combining Shapes

Joy supports + operator to join shapes.

def donut(x, y, r):
    c1 = circle(x=x, y=y, r=r)
    c2 = circle(x=x, y=y, r=r/2)
    return c1+c2

d = donut(0, 0, 100)
show(d)

svg

Transformations

Joy supports translate, rotate and scale transformations. Transformations are applied using | operator.

shape = circle(r=50) | translate(x=100, y=0)
show(shape)

svg

Transformations can be chained too.

r1 = rectangle(w=200, h=200)
r2 = r1 | rotate(angle=45) | scale(1/SQRT2)
show(r1, r2)

svg

Higer-Order Transformations

Joy supports higher-order transformation repeat.

The repeat transformation applies a transformation multiple times and combines all the resulting shapes.

For example, draw 10 circles:

c = circle(x=-100, y=0, r=50)
shape = c | Repeat(10, Translate(x=10, y=0)
show(shape)

svg

Combined with rotation, it can create amusing patterns.

shape = line() | repeat(18, rotate(angle=10))
show(shape)

svg

We could do the same with a square:

shape = rectangle(w=200, h=200) | repeat(18, rotate(angle=10))
show(shape)

svg

or a rectangle:

shape = rectangle(w=200, h=100) | repeat(18, rotate(angle=10))
show(shape)

svg

We can combine multiple transformations and repeat.

shape = rectangle(w=300, h=300) | repeat(72, rotate(360/72) | scale(0.92))
show(shape)

svg

You can try the same with a circle too:

c = circle(x=100, y=0, radius=50)
shape = c | repeat(36*4, rotate(10) | scale(0.97))
show(shape)

svg

For more information, please checkout the tutorial.

Tutorial

See tutorial.ipynb.

Acknowledgements

Special thanks to Amit Kapoor (@amitkaps). This library woundn't have been possible without his inputs.

The long discussions between @anandology and @amitkaps on functional programming and computational artistry (for almost over an year) and the initial experiments were some of the seeds that gave life to this library.

License

This repository has been released under the MIT License.

Owner
FOSS United Foundation
Non-profit foundation that aims at promoting and strengthening the Free and Open Source Software community and ecosystem in India and elsewhere.
FOSS United Foundation
An echo kernel for JupyterLite

jupyterlite-echo-kernel An echo kernel for JupyterLite. Requirements JupyterLite = 0.1.0a10 Install To install the extension, execute: pip install ju

JupyterLite 7 Dec 07, 2022
Wasm powered Jupyter running in the browser 💡

JupyterLite JupyterLite is a JupyterLab distribution that runs entirely in the browser built from the ground-up using JupyterLab components and extens

JupyterLite 3k Jan 04, 2023
Automatically detect obfuscated code and other state machines

Scripts to automatically detect obfuscated code and state machines in binaries.

Aaron 110 Dec 04, 2022
ROS2 Docker tutorial with VSCode

ROS2-Docker-tutorial I made this repository using athackst/vscode_ros2_workspace templete with foxy-nvidia branch. You could see more information abov

Tae Young Kim 4 Nov 03, 2022
Run context-aware commands from your source code comments

Run context-aware commands from your source code comments. Codeline allows you to run custom commands directly from source-code comments, combining th

Rory Byrne 32 Nov 09, 2021
Python Indent - Correct python indentation in Visual Studio Code.

Python Indent Correct python indentation in Visual Studio Code. See the extension on the VSCode Marketplace and its source code on GitHub. Please cons

Kevin Rose 57 Dec 15, 2022
Jarvide - A powerful AI mixed with a powerful IDE.

Jarvide About Jarvide Welcome to Jarvide. A powerful AI mixed with a powerful ID

Caeden 23 Oct 28, 2022
CTO (Call Tree Overviewer) is an IDA plugin for creating a simple and efficiant function call tree graph

CTO (Call Tree Overviewer) CTO (Call Tree Overviewer) is an IDA plugin for creating a simple and efficiant function call tree graph. It can also summa

Hiroshi Suzuki 257 Dec 24, 2022
notebookJS: seamless JavaScript integration in Python Notebooks

notebookJS enables the execution of custom JavaScript code in Python Notebooks (Jupyter Notebook and Google Colab). This Python library can be useful for implementing and reusing interactive Data Vis

jorgehpo 146 Dec 07, 2022
Python IDE or notebook to generate a basic Kepler.gl data visualization

geospatial-data-analysis [readme] Use this code in your Python IDE or notebook to generate a basic Kepler.gl data visualization, without pre-configura

2 Sep 05, 2022
This is a backend for VCode Editor for saving & retriving data.

This is a backend for VCode Editor for saving & retriving data through the API.

Tejas Magade 1 Nov 22, 2021
Mu - A Simple Python Code Editor

A small, simple editor for beginner Python programmers. Written in Python and Qt5.

Mu 1.2k Jan 03, 2023
Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser

Live Coding in Python Visualize your Python code while you type it in PyCharm, Emacs, Sublime Text, or even your browser. To see how to use one of the

Don Kirkby 256 Dec 14, 2022
VSCode Development Container Template

VSCode Development Container Template This template enables you to use a full-fledged containerized development environment for your machine learning

Paige Bailey 10 Oct 10, 2022
💻 Open recent VS Code folders and files using Ulauncher

ulauncher-vscode-recent 💻 Open recent VS Code folders and files using Ulauncher. Quickly open recently-opened VS Code project directories and files.

Mihir Chaturvedi 14 Nov 24, 2022
Kite IntelliJ plugin

Handbook Supported platforms The Kite plugin supports the following environments: PyCharm Community PyCharm Professional IntelliJ Community with the P

Kite 57 Dec 23, 2022
Shows Odin Lang errors in Sublime Text.

OdinErrors Shows Odin Lang errors in Sublime Text. Config Collections and defines are stored in ols.json (Hijacked from ols). { "collections": [

Gus 3 Nov 20, 2021
Clarity mode is a single-notebook interface built with existing JupyterLab components.

JupyterLab Clarity Mode Clarity mode is a single-notebook interface built with existing JupyterLab components. To install: Clone this repository Ensur

10 Jul 20, 2022
Launch a ready-to-code Wagtail Live development environment with a single click.

Wagtail Live Gitpod Launch a ready-to-code Wagtail Live development environment with a single click. Steps: Click the Open in Gitpod button. Relax: a

Coen van der Kamp 6 Oct 29, 2021
Integrate clang-format with Sublime Text

Sublime Text Clang Format Plugin This is a minimal plugin integrating clang-format with Sublime Text, with emphasis on the word minimal. It is not rea

Jon Palmisciano 1 Dec 17, 2021