Skip to main content

Simple tool to allow to transcrypt Python code that uses P5.js

Project description

Python to P5.js Transcriptor

This project started from a proof of concept based in Axel Tanner's "Transcrypt & p5js" blogpost. The project's main goal was to use Tanner's approach combined with decorator and global variables control to enable P5.js API from being called "directly" from the Python code as clean as possible.

Here's an example of a valid Python code using P5.js API:

from pytop5js import *

def setup():
    createCanvas(200, 200)
    background(160)


def draw():
    fill('blue')
    background(200)
    r = sin(frameCount / 60) * 50 + 50
    ellipse(100, 100, r, r)


start_p5(setup, draw)

Installation

The project is not under Pypi yet, so you'll have to install it from the git repo. To do so, just run:

$ pip install git+https://github.com/berinhard/pyp5js.git@master  # python 3 only

Usage

Since you'll be writting Python code and then generating the correspondent P5.js code from it, pyp5js provides a simple command line API to help you to generate the files.

So, to start a new sketch, you'll have to run:

$ pyp5js new my_sketch

This command will create a directory with the following code structure:

~ my_sketch/
  ~ static /
    - p5.js
  - index.html
  - my_sketch.py

The index.html is prepared to display your sketch, so you'll have to keep on opening it to refresh see results from the code you'll add to my_sketch.py.

After updating your code, you'll have to run the transcrypt command to update the files. Run it as:

$ pyp5js transcrypt my_sketch

The way the code is implemented, for now, you'll have to execute it from the same directory-level where my_sketch is - you can't run it from inside the my_sketch directory.

If you're lazy as me, you can use the monitor command instead of the previous one. The command will monitor your sketch directory and keep track of any changes on any .py files. When it notices a new change, it automatically runs the transcrypt process for you. So, now you'll just have to refresh your index.html file to see the results.

$ pyp5js monitor my_sketch

All of the command-line interface methods have a few optional arguments and you can check them by running:

$ pyp5js --help

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

pyp5js-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

pyp5js-0.0.2-py3-none-any.whl (547.9 kB view details)

Uploaded Python 3

File details

Details for the file pyp5js-0.0.2.tar.gz.

File metadata

  • Download URL: pyp5js-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for pyp5js-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b5d704670217782798fd5d033f0953c76a43f94e62fc84d07124e6d24ab5aba6
MD5 b0817f744947ce94bc5343854b08eb3a
BLAKE2b-256 de61d9660148008fe31209a37219afd082ca18e9f20f766f9b1275824a6a2481

See more details on using hashes here.

Provenance

File details

Details for the file pyp5js-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyp5js-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 547.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for pyp5js-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1be7db72633b5e914d8395aee7cadb418f121fb2662d9c7cc60c8ad9ef7aa9c
MD5 faf8a16b98b803a25c6e7811816ae996
BLAKE2b-256 fc0f18d10dee8fc677acc057c6a2f2a3760ea9d24ef1db1138ec7707196bcb9b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page