Skip to main content

Python port of a subset of the Processing API

Project description

Plus5

Python3 port of a subset of the Processing API.

Inspired by p5, Plus5 uses PyGame library to implement a subset of the Processing API. It's in an early stage but works very fast, thanks to PyGame.

Requirements

The current requirements are Python3 and PyGame. PyGame uses Simple Directmedia Layer (SDL). In order to use fonts, sdl2-ttf must be also installed in the systems.

  • Python3
  • PyGame >= 1.9.
  • libsdl2-ttf

Plus5, Python3, PyGame and SDL are supported in multiple operating systems (Linux, Windows, Mac).

Installation

Using pip

$ pip install -r requirements.txt
$ pip install plus5

Using git

$ git clone https://github.com/vrruiz/plus5/
$ cd plus5/
$ python3 setup.py install

libsdl2-ttf

In some operating systems, this library must be installed manually.

Usage

Example. A rectangle follows the mouse pointer.

from plus5 import *

def setup():
    size(500,500)

def draw():
    background(127,0,0)
    stroke(255)
    fill(0,127,0)
    rect(mouseX - 25, mouseY - 25, 50, 50)

run()

Reference

Usually, the calls are the same as in Processing.py Reference.

Structure

draw()
exit()
noLoop()
setup()
size(width, height)
redraw()
run()

Environment

delay(milliseconds)
displayHeight
displayWidth
frameCount
frameRate
height
size()
width

Color

background(color)
color(color)
fill(color)
noFill()
noStroke()
stroke(width)
strokeWeight(weight)

Input

key
keyCode
keyIsPressed
keyPressed()
keyReleased()
mouseIsPressed
mousePressed()
mouseReleased()
mouseX
mouseY
pmouseX
pmouseY

Output

save()

Shape

arc(x, y, width, height, start, stop)
circle(a, b, extent)
ellipse(x, y, width, height)
line(x1, y1, x2, y2)
point(x, y)
quad(x1, y1, x2, y2, x3, y3, x4, y4)
rect(x, y, width, height)
square(a, b, extent)
triangle(x1, y1, x2, y2, x3, y3)

Text

text(string, x, y)
textSize(size)
textFont(font, size)
loadFont(name)
createFont(name, size)

Image

loadImage(filename)
image(img, x, y)

Math

acos(value)
asin(value)
atan(value)
atan2(y, x)
ceil(n)
cos(radians)
degrees(radians)
exp(n)
floor(n)
log(n)
radians(degrees)
sin(radians)
sqrt(n)
tan(radians)

Constants

PI = 3.14159265358979323846
TWO_PI = 6.28318530717958647693
HALF_PI =1.57079632679489661923
TAU = 6.28318530717958647693
HALF_PI = 0.7853982

Tutorials

Author

Víctor R. Ruiz rvr@linotipo.es

License

MIT

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

plus5-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plus5-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file plus5-0.1.2.tar.gz.

File metadata

  • Download URL: plus5-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for plus5-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fa68106e61c8ef38a8d68495ea5d73986b78d3425c1593860b5dca8e0ea66203
MD5 51c77379916d981400f304380b07a791
BLAKE2b-256 069d91252646afb6850ca6ce9a4063e4c593fd08f16de5bf10f103df657c93c7

See more details on using hashes here.

File details

Details for the file plus5-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: plus5-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for plus5-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6aa3b87a11a19ad10c57cf4a78f3c27098736af9c07eacb1df639721b04ce062
MD5 028139123165f9dc8ee0ad300aef8e1a
BLAKE2b-256 c3e9c0bd819ad559216f1c5c8ff761798ffa05e3faa0d20e38d59cd431dc56f3

See more details on using hashes here.

Supported by

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