-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdocs
95 lines (75 loc) · 4.57 KB
/
docs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
P5
setup w h called once before starting the draw loop
draw w h called every frame
size←w h set window size (do this outside of setup/draw)
smooth←i set the smoothness (0 is none). (do this outside of setup/draw)
cursor type set the cursor to the specified type - string of cross, hand, arrow, move, text & wait, or ⍬ for no cursor, or an APLImg for a custom one
scroll|sc dir: called when mouse wheel is scrolled. ⍵ positive = up/away from user, negative = down/towards
scrollup|scu dir: called when direction of scroll is positive, otherwise as above
scrolldown|scd dir: called when direction of scroll is negative, otherwise as above
mod keypress|kp key called when a key is pressed; key = char vector; mod = (ctrl shift alt altgr meta)
modpress|mp mod called when a modifer key is pressed; mod = [ctrl|shift|alt|altgr]
mod keyrelease|kr key: called when a key is released; key = char vector; mod = (ctrl shift alt altgr meta)
modrelease|mr mod: called when a modifer key is released; mod = [ctrl|shift|alt|altgr]
dispsize | ds: array of display width & height
displaywidth | dw: display width
displayheight | dh: display height
width | w : width of the canvas
height | h : height of the canvas
mousex | mx : mouse X position
mousey | my : mouse Y position
pmousex | pmx : previous mouse X position
pmousey | pmy : previous mouse Y position
mousepos | mpos: array of mouse X & Y
pmousepos | pmpos: array of previous mouse X & Y
key: last key pressed
pressed key: check whether key is currently pressed. check key names with P5.lm←{⎕←⍵}
A (p lerp) B: lerp colors. p→0 prefers A, p→1 prefers B. vectorizes A & B
fps|framerate : framerate
fc|framecount: frame count since starting
color|col: convert char vector to a number representing the color
exit code: System.exit(code)
LM & RM & MM:
mouse object for the left, middle, & right button respectively
clicked|c mpos: called when the mouse button is clicked with ⍵ = P5.mpos
spos released|r mpos: called when the mouse button is clicked with ⍵ = P5.mpos & ⍺=sp
startx|sx : mouse X when the button was started to be held
starty|sy : mouse Y when the button was started to be held
startpos|sp|s: array of sx & sy
pressed|p : is this button pressed
ppressed|pp : was this button pressed last frame
bytes path: returns an array of bytes in file at the specified path
lines path: returns an array of lines of file at the specified path
image|img path: returns an APLImg object with the image at the specified path
image|img mat : returns an APLImg with the colors from the matrix
APLImg:
width|w: get the width of the image
height|h: get the height of the image
G:
fill ←col: set the fill color (set to ⍬ for noFill)
stroke←col: set the stroke color (set to ⍬ for noStroke)
textsize←size: set text size
bg|background col: color the canvas to the color
x y text 'text': draw that text at (x;y)
x y img|image Img: draw the image at the specified coordinates
x y x2 y2 img|image Img: draw the image between the specified coordinates
x y scale img|image Img: draw the image with the top-left corner being (x; y) with the given scale (0 = 0%, 1 = 100%)
textalign|ta h: set horizontal text-aligning to either left, right or center
v textalign|ta h: set horizontal text-aligning to either left, right or center & vertical to bottom, center or top
Further on, "pts" arguments can either be number vector or number vector vectors, the latter scattering the operation for each. aka ⍥1, when that gets implemented
[type] rect pts: draw a rectangle. type can be:
corner: x1 y1 w h←pts
corners: x1 y1 x2 y2←pts (default)
center: centerx centery w h←ptr
radius: center←pts[1 2]⋄w h←pts[3 4]×2
[type] ellipse pts: draw an ellipse. type can be:
corner: x1 y1 w h←pts
corners: x1 y1 x2 y2←pts (default)
center: centerx centery w h←ptr
radius: center←pts[1 2]⋄w h←pts[3 4]×2
[type] cicle pts: draw a circle. type can be:
center: centerX centerY w h←ptr
radius: center←pts[1 2]⋄w h←pts[3 4]×2
point|pt pts: draw single pixels at (x; y) pairs of the array
[weight] line|ln pts: connect the points - every 2 items in ⍵; weight default is 1; WARNING this does P5.G.fill ← ⍬
[weight] loop pts: draw closed loop(s) of the points of the array; weight default is 1