p5-python 0.5.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- p5/__init__.py +49 -0
- p5/__main__.py +50 -0
- p5/color.py +80 -0
- p5/constants.py +133 -0
- p5/corefunctions.py +525 -0
- p5/drawcurve.py +146 -0
- p5/mathfunctions.py +149 -0
- p5/p5-python.png +0 -0
- p5/renderer.py +221 -0
- p5/settings.py +58 -0
- p5/timedata.py +30 -0
- p5/transform.py +78 -0
- p5_python-0.5.4.dist-info/METADATA +15 -0
- p5_python-0.5.4.dist-info/RECORD +16 -0
- p5_python-0.5.4.dist-info/WHEEL +5 -0
- p5_python-0.5.4.dist-info/top_level.txt +1 -0
p5/__init__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
3
|
+
|
|
4
|
+
from p5.corefunctions import (run, createCanvas, saveCanvas, angleMode,
|
|
5
|
+
line, ellipse, circle, rect, quad, arc, triangle,
|
|
6
|
+
point, beginShape, vertex, curveVertex,
|
|
7
|
+
endShape, cursor, strokeWeight, noStroke,
|
|
8
|
+
loadImage, image, keyIsDown, frameRate, loop, noLoop,
|
|
9
|
+
background,text,textFont, textSize, textStyle, textAlign)
|
|
10
|
+
|
|
11
|
+
from p5.constants import (TWO_PI, HALF_PI, PI, QUARTER_PI, TAU, CURSOR_ARROW, CURSOR_DIAMOND,
|
|
12
|
+
CURSOR_BROKEN_X, CURSOR_TRI_LEFT, CURSOR_TRI_RIGHT, BOLD, ITALIC, BOLDITALIC, NORMAL,
|
|
13
|
+
BACKSPACE,TAB,RETURN,ENTER,PAUSE,ESCAPE,SPACE,DELETE,EXCLAIM,QUOTEDBL,HASH,DOLLAR,AMPERSAND,QUOTE,LEFTPAREN,RIGHTPAREN,
|
|
14
|
+
ASTERISK,PLUS,COMMA,MINUS,PERIOD,SLASH,COLON,SEMICOLON,LESS,EQUALS,GREATER,QUESTION,AT,LEFTBRACKET,RIGHTBRACKET,CARET,
|
|
15
|
+
UNDERSCORE,BACKQUOTE,UP,DOWN,RIGHT,LEFT,UP_ARROW,DOWN_ARROW,LEFT_ARROW,RIGHT_ARROW,INSERT,HOME,END,PAGEUP,PAGEDOWN,PGUP,
|
|
16
|
+
PGDN,KP0,KP1,KP2,KP3,KP4,KP5,KP6,KP7,KP8,KP9,KP_PERIOD,KP_DIVIDE,KP_MULTIPLY,KP_MINUS,KP_PLUS,F1,F2,F3,F4,F5,
|
|
17
|
+
F6,F7,F8,F9,F10,F11,F12,NUMLOCK,CAPSLOCK,SCROLLOCK,RSHIFT,LSHIFT,RCTRL,LCTRL,RALT,LALT,RMETA,LMETA,CONTEXTMENU,
|
|
18
|
+
PRINT,SYSREQ,BREAK,MENU,CENTER,CLOSE,RADIANS,DEGREES, CORNER, CORNERS, RADIUS,CHORD, PIE, OPEN, ARC)
|
|
19
|
+
|
|
20
|
+
from p5.mathfunctions import (pow, map, randomSeed, random, constrain, floor, ceil, dist, exp, lerp, log, log10, log2, logb, mag,
|
|
21
|
+
rerange, norm, sq, sqrt, frac, sin, cos, tan, asin, acos, atan, atan2, degrees, radians, integral)
|
|
22
|
+
|
|
23
|
+
from p5.color import (fill,noFill, stroke, red, green, blue, brightness, hue, lightness, saturation, lerpColor, color, alpha)
|
|
24
|
+
|
|
25
|
+
from p5.timedata import (hour, minute, second, day, month, year, milli_sec, millis)
|
|
26
|
+
|
|
27
|
+
from p5.drawcurve import (bezier,spline)
|
|
28
|
+
|
|
29
|
+
from p5.transform import (scale, rotate, translate, push, pop, resetMatrix)
|
|
30
|
+
|
|
31
|
+
__all__ = ["run", "createCanvas", "translate", "background", "fill", "noFill", "line", "ellipse", "circle", "rect", "triangle", "quad", "arc",
|
|
32
|
+
"push", "pop", "cursor", "TWO_PI", "HALF_PI", "PI", "QUARTER_PI", "TAU", "CURSOR_ARROW", "CURSOR_DIAMOND", "CURSOR_BROKEN_X", "CURSOR_TRI_LEFT",
|
|
33
|
+
"CURSOR_TRI_RIGHT", "BOLD", "ITALIC", "BOLDITALIC", "NORMAL", "strokeWeight", "stroke", "noStroke", "loadImage", "image", "point", "CORNER", "CORNERS", "RADIUS",
|
|
34
|
+
"frameRate", "random", "constrain", "floor", "ceil", "dist", "exp", "lerp", "log", "log10", "log2", "logb", "mag", "textAlign", "CHORD", "PIE", "OPEN", "ARC",
|
|
35
|
+
"rerange", "norm", "sq", "sqrt", "frac", "sin", "cos", "tan", "asin", "acos", "atan", "atan2", "degrees", "radians", "loop", "noLoop", "integral",
|
|
36
|
+
"text","textFont", "textSize", "textStyle","beginShape", "vertex", "endShape", "keyIsDown", "saveCanvas", "scale", "rotate", "translate",
|
|
37
|
+
"BACKSPACE","TAB","RETURN","ENTER","PAUSE","ESCAPE","SPACE","DELETE","EXCLAIM","QUOTEDBL","HASH","DOLLAR","AMPERSAND","QUOTE","LEFTPAREN","RIGHTPAREN",
|
|
38
|
+
"ASTERISK","PLUS","COMMA","MINUS","PERIOD","SLASH","COLON","SEMICOLON","LESS","EQUALS","GREATER","QUESTION","AT","LEFTBRACKET","RIGHTBRACKET","CARET",
|
|
39
|
+
"UNDERSCORE","BACKQUOTE","UP","DOWN","RIGHT","LEFT","UP_ARROW","DOWN_ARROW","LEFT_ARROW","RIGHT_ARROW","INSERT","HOME","END","PAGEUP","PAGEDOWN","PGUP",
|
|
40
|
+
"PGDN","KP0","KP1","KP2","KP3","KP4","KP5","KP6","KP7","KP8","KP9","KP_PERIOD","KP_DIVIDE","KP_MULTIPLY","KP_MINUS","KP_PLUS","F1","F2","F3","F4","F5",
|
|
41
|
+
"F6","F7","F8","F9","F10","F11","F12","NUMLOCK","CAPSLOCK","SCROLLOCK","RSHIFT","LSHIFT","RCTRL","LCTRL","RALT","LALT","RMETA","LMETA","CONTEXTMENU",
|
|
42
|
+
"PRINT","SYSREQ","BREAK","MENU","CENTER","CLOSE", "pow", "map", "angleMode", "curveVertex", "randomSeed", "resetMatrix",
|
|
43
|
+
"hour", "minute", "second", "day", "month", "year", "milli_sec", "millis", "bezier", "spline"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
__version__ = "0.5.04"
|
|
47
|
+
|
|
48
|
+
print("Thank you for using p5\n")
|
|
49
|
+
|
p5/__main__.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Part of p5: A Python package based on Processing
|
|
3
|
+
# Copyright (C) 2017-2019 Abhik Pal
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful, but
|
|
11
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
# General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
from . import p5
|
|
20
|
+
|
|
21
|
+
# we should be parsing sys args here and expose a series of commands
|
|
22
|
+
# similar to processing-java.
|
|
23
|
+
#
|
|
24
|
+
# relevant output from `processing-java --help`:
|
|
25
|
+
#
|
|
26
|
+
# --help Show this help text. Congratulations.
|
|
27
|
+
#
|
|
28
|
+
# --sketch=<name> Specify the sketch folder (required)
|
|
29
|
+
#
|
|
30
|
+
# --output=<name> Specify the output folder (optional and
|
|
31
|
+
# cannot be the same as the sketch folder.)
|
|
32
|
+
#
|
|
33
|
+
# --force The sketch will not build if the output
|
|
34
|
+
# folder already exists, because the contents
|
|
35
|
+
# will be replaced. This option erases the
|
|
36
|
+
# folder first. Use with extreme caution!
|
|
37
|
+
#
|
|
38
|
+
# --build Preprocess and compile a sketch into .class files.
|
|
39
|
+
#
|
|
40
|
+
# --run Preprocess, compile, and run a sketch.
|
|
41
|
+
#
|
|
42
|
+
# --present Preprocess, compile, and run a sketch in presentation mode.
|
|
43
|
+
#
|
|
44
|
+
# --export Export an application.
|
|
45
|
+
#
|
|
46
|
+
# --no-java Do not embed Java. Use at your own risk!
|
|
47
|
+
#
|
|
48
|
+
# --platform Specify the platform (export to application only).
|
|
49
|
+
# Should be one of 'windows', 'macosx', or 'linux'.
|
|
50
|
+
#
|
p5/color.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from p5.settings import *
|
|
2
|
+
from pygame import Color
|
|
3
|
+
|
|
4
|
+
# COLOR
|
|
5
|
+
def get_Color(c, a=255):
|
|
6
|
+
color = None
|
|
7
|
+
if (type(c) == int) and (0 <= c) and (255 >= c):
|
|
8
|
+
color = Color(c, c, c)
|
|
9
|
+
elif (type(c) == float) and (0 <= c) and (255 >= c):
|
|
10
|
+
color = Color(int(c), int(c), int(c))
|
|
11
|
+
elif (type(c) == str):
|
|
12
|
+
color = Color(c)
|
|
13
|
+
elif (type(c) == tuple):
|
|
14
|
+
color = Color(c)
|
|
15
|
+
else:
|
|
16
|
+
color = Color("black")
|
|
17
|
+
color.a = a
|
|
18
|
+
return color
|
|
19
|
+
|
|
20
|
+
def set_colors(*args):
|
|
21
|
+
if len(args)==1 :
|
|
22
|
+
return get_Color(args[0])
|
|
23
|
+
if len(args)==2 :
|
|
24
|
+
return get_Color(args[0],args[1])
|
|
25
|
+
if len(args)==3 :
|
|
26
|
+
return get_Color((args[0],args[1],args[2]))
|
|
27
|
+
if len(args)==4 :
|
|
28
|
+
return get_Color((args[0],args[1],args[2]),args[3])
|
|
29
|
+
|
|
30
|
+
def fill(*args): # set fill color
|
|
31
|
+
settings["fill_color"] = set_colors(*args)
|
|
32
|
+
settings["no_fill"] = False
|
|
33
|
+
settings["text_color"] = settings["fill_color"]
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
def noFill():
|
|
37
|
+
settings["no_fill"] = True
|
|
38
|
+
fill_color = settings["fill_color"]
|
|
39
|
+
fill_color[3] = 0
|
|
40
|
+
settings["fill_color"] = fill_color
|
|
41
|
+
settings["text_color"] = settings["fill_color"]
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
def stroke(*args):
|
|
45
|
+
settings["stroke_color"] = set_colors(*args)
|
|
46
|
+
settings["no_stroke"] = False
|
|
47
|
+
settings["text_outline"] = settings["stroke_color"]
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
def color(r, g, b):
|
|
51
|
+
return Color(r, g, b)
|
|
52
|
+
|
|
53
|
+
def alpha(c):
|
|
54
|
+
return c.a
|
|
55
|
+
|
|
56
|
+
def red(c):
|
|
57
|
+
return c.r
|
|
58
|
+
|
|
59
|
+
def green(c):
|
|
60
|
+
return c.g
|
|
61
|
+
|
|
62
|
+
def blue(c):
|
|
63
|
+
return c.b
|
|
64
|
+
|
|
65
|
+
def brightness(c):
|
|
66
|
+
return c.hsva[2]
|
|
67
|
+
|
|
68
|
+
def hue(c):
|
|
69
|
+
return c.hsva[0]
|
|
70
|
+
|
|
71
|
+
def lightness(c):
|
|
72
|
+
return c.hsla[2]
|
|
73
|
+
|
|
74
|
+
def saturation(c):
|
|
75
|
+
return c.hsla[1]
|
|
76
|
+
|
|
77
|
+
def lerpColor(c1, c2, amnt):
|
|
78
|
+
return c1.lerp(c2, amnt)
|
|
79
|
+
|
|
80
|
+
|
p5/constants.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from math import pi, tau
|
|
2
|
+
import pygame.cursors
|
|
3
|
+
|
|
4
|
+
# CONSTANTS
|
|
5
|
+
TWO_PI = pi*2.0
|
|
6
|
+
HALF_PI = pi/2.0
|
|
7
|
+
PI = pi
|
|
8
|
+
QUARTER_PI = pi/4.0
|
|
9
|
+
TAU = tau
|
|
10
|
+
|
|
11
|
+
CURSOR_ARROW = pygame.cursors.arrow
|
|
12
|
+
CURSOR_DIAMOND = pygame.cursors.diamond
|
|
13
|
+
CURSOR_BROKEN_X = pygame.cursors.broken_x
|
|
14
|
+
CURSOR_TRI_LEFT = pygame.cursors.tri_left
|
|
15
|
+
CURSOR_TRI_RIGHT = pygame.cursors.tri_right
|
|
16
|
+
|
|
17
|
+
CLOSE = "close"
|
|
18
|
+
CENTER = "center"
|
|
19
|
+
BOLD = "bold"
|
|
20
|
+
ITALIC = "italic"
|
|
21
|
+
BOLDITALIC = "bolditalic"
|
|
22
|
+
NORMAL = "normal"
|
|
23
|
+
RADIANS = "radians"
|
|
24
|
+
DEGREES = "degrees"
|
|
25
|
+
CORNER = "corner"
|
|
26
|
+
CORNERS = "corners"
|
|
27
|
+
RADIUS = "radius"
|
|
28
|
+
CHORD = "chord"
|
|
29
|
+
PIE = "pie"
|
|
30
|
+
OPEN = "open"
|
|
31
|
+
ARC = "arc"
|
|
32
|
+
|
|
33
|
+
# keys aliases
|
|
34
|
+
BACKSPACE = "backspace"
|
|
35
|
+
TAB = "tab"
|
|
36
|
+
RETURN = "return"
|
|
37
|
+
ENTER = "enter"
|
|
38
|
+
PAUSE = "pause"
|
|
39
|
+
ESCAPE = "escape"
|
|
40
|
+
SPACE = "space"
|
|
41
|
+
DELETE = "delete"
|
|
42
|
+
|
|
43
|
+
EXCLAIM = "!"
|
|
44
|
+
QUOTEDBL = '"'
|
|
45
|
+
HASH = "#"
|
|
46
|
+
DOLLAR = "$"
|
|
47
|
+
AMPERSAND = "&"
|
|
48
|
+
QUOTE = "'"
|
|
49
|
+
LEFTPAREN = "("
|
|
50
|
+
RIGHTPAREN = ")"
|
|
51
|
+
ASTERISK = "*"
|
|
52
|
+
PLUS = "+"
|
|
53
|
+
COMMA = ","
|
|
54
|
+
MINUS = "-"
|
|
55
|
+
PERIOD = "."
|
|
56
|
+
SLASH = "/"
|
|
57
|
+
|
|
58
|
+
COLON = ":"
|
|
59
|
+
SEMICOLON = ";"
|
|
60
|
+
LESS = "<"
|
|
61
|
+
EQUALS = "="
|
|
62
|
+
GREATER = ">"
|
|
63
|
+
QUESTION = "?"
|
|
64
|
+
AT = "@"
|
|
65
|
+
LEFTBRACKET = "["
|
|
66
|
+
RIGHTBRACKET = "]"
|
|
67
|
+
CARET = "^"
|
|
68
|
+
UNDERSCORE = "_"
|
|
69
|
+
BACKQUOTE = "`"
|
|
70
|
+
|
|
71
|
+
UP = "up arrow"
|
|
72
|
+
DOWN = "down arrow"
|
|
73
|
+
RIGHT = "right arrow"
|
|
74
|
+
LEFT = "left arrow"
|
|
75
|
+
UP_ARROW = "up arrow"
|
|
76
|
+
DOWN_ARROW = "down arrow"
|
|
77
|
+
LEFT_ARROW = "left arrow"
|
|
78
|
+
RIGHT_ARROW = "right arrow"
|
|
79
|
+
INSERT = "insert"
|
|
80
|
+
HOME = "home"
|
|
81
|
+
END = "end"
|
|
82
|
+
PAGEUP = "page up"
|
|
83
|
+
PAGEDOWN = "page down"
|
|
84
|
+
PGUP = "page up"
|
|
85
|
+
PGDN = "page down"
|
|
86
|
+
|
|
87
|
+
KP0 = "[0]"
|
|
88
|
+
KP1 = "[1]"
|
|
89
|
+
KP2 = "[2]"
|
|
90
|
+
KP3 = "[3]"
|
|
91
|
+
KP4 = "[4]"
|
|
92
|
+
KP5 = "[5]"
|
|
93
|
+
KP6 = "[6]"
|
|
94
|
+
KP7 = "[7]"
|
|
95
|
+
KP8 = "[8]"
|
|
96
|
+
KP9 = "[9]"
|
|
97
|
+
|
|
98
|
+
KP_PERIOD = "[.]"
|
|
99
|
+
KP_DIVIDE = "[/]"
|
|
100
|
+
KP_MULTIPLY = "[*]"
|
|
101
|
+
KP_MINUS = "[-]"
|
|
102
|
+
KP_PLUS = "[+]"
|
|
103
|
+
|
|
104
|
+
F1 = "f1"
|
|
105
|
+
F2 = "f2"
|
|
106
|
+
F3 = "f3"
|
|
107
|
+
F4 = "f4"
|
|
108
|
+
F5 = "f5"
|
|
109
|
+
F6 = "f6"
|
|
110
|
+
F7 = "f7"
|
|
111
|
+
F8 = "f8"
|
|
112
|
+
F9 = "f9"
|
|
113
|
+
F10 = "f10"
|
|
114
|
+
F11 = "f11"
|
|
115
|
+
F12 = "f12"
|
|
116
|
+
|
|
117
|
+
NUMLOCK = "numlock"
|
|
118
|
+
CAPSLOCK = "capslock"
|
|
119
|
+
SCROLLOCK = "scrollock"
|
|
120
|
+
RSHIFT = "right shift"
|
|
121
|
+
LSHIFT = "left shift"
|
|
122
|
+
RCTRL = "right control"
|
|
123
|
+
LCTRL = "left control"
|
|
124
|
+
RALT = "right alt"
|
|
125
|
+
LALT = "left alt"
|
|
126
|
+
RMETA = "right meta"
|
|
127
|
+
LMETA = "left meta"
|
|
128
|
+
CONTEXTMENU = "compose"
|
|
129
|
+
PRINT = "print screen"
|
|
130
|
+
SYSREQ = "sysrq"
|
|
131
|
+
BREAK = "break"
|
|
132
|
+
MENU = "menu"
|
|
133
|
+
|