项目作者: vrruiz

项目描述 :
Python3 port of a subset of the Processing API.
高级语言: Python
项目地址: git://github.com/vrruiz/plus5.git
创建时间: 2021-01-06T12:45:44Z
项目社区:https://github.com/vrruiz/plus5

开源协议:MIT License

下载


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

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

Using git

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

libsdl2-ttf

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

Usage

Example. A rectangle follows the mouse pointer.

  1. from plus5 import *
  2. def setup():
  3. size(500,500)
  4. def draw():
  5. background(127,0,0)
  6. stroke(255)
  7. fill(0,127,0)
  8. rect(mouseX - 25, mouseY - 25, 50, 50)
  9. run()

Reference

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

Structure

  1. draw()
  2. exit()
  3. noLoop()
  4. setup()
  5. size(width, height)
  6. redraw()
  7. run()

Environment

  1. delay(milliseconds)
  2. displayHeight
  3. displayWidth
  4. frameCount
  5. frameRate
  6. height
  7. size()
  8. width

Color

  1. background(color)
  2. color(color)
  3. fill(color)
  4. noFill()
  5. noStroke()
  6. stroke(width)
  7. strokeWeight(weight)

Input

  1. key
  2. keyCode
  3. keyIsPressed
  4. keyPressed()
  5. keyReleased()
  6. mouseIsPressed
  7. mousePressed()
  8. mouseReleased()
  9. mouseX
  10. mouseY
  11. pmouseX
  12. pmouseY

Output

  1. save()

Shape

  1. arc(x, y, width, height, start, stop)
  2. circle(a, b, extent)
  3. ellipse(x, y, width, height)
  4. line(x1, y1, x2, y2)
  5. point(x, y)
  6. quad(x1, y1, x2, y2, x3, y3, x4, y4)
  7. rect(x, y, width, height)
  8. square(a, b, extent)
  9. triangle(x1, y1, x2, y2, x3, y3)

Text

  1. text(string, x, y)
  2. textSize(size)
  3. textFont(font, size)
  4. loadFont(name)
  5. createFont(name, size)

Image

  1. loadImage(filename)
  2. image(img, x, y)

Math

  1. acos(value)
  2. asin(value)
  3. atan(value)
  4. atan2(y, x)
  5. ceil(n)
  6. cos(radians)
  7. degrees(radians)
  8. exp(n)
  9. floor(n)
  10. log(n)
  11. radians(degrees)
  12. sin(radians)
  13. sqrt(n)
  14. tan(radians)

Constants

  1. PI = 3.14159265358979323846
  2. TWO_PI = 6.28318530717958647693
  3. HALF_PI =1.57079632679489661923
  4. TAU = 6.28318530717958647693
  5. HALF_PI = 0.7853982

Tutorials

Author

Víctor R. Ruiz rvr@linotipo.es

License

MIT