-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathp5-example.js
More file actions
48 lines (41 loc) · 976 Bytes
/
p5-example.js
File metadata and controls
48 lines (41 loc) · 976 Bytes
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
/* MoMath Math Square Behavior
*
* Title: P5 Example
* Description: Display user blobs and sensors (same as debug)
* Scheduler ID:
* Framework: P5
* Author: Dylan Simon <dylan@dylex.net>
* Created: 2017-04
* Status: works
*/
import P5Behavior from 'p5beh';
const pb = new P5Behavior();
// for WEBGL: pb.renderer = 'webgl';
pb.preload = function (p) {
/* this == pb.p5 == p */
// ...
}
pb.setup = function (p) {
/* this == pb.p5 == p */
/* P5Behavior already calls createCanvas for us */
// setup here...
};
pb.draw = function (floor, p) {
/* this == pb.p5 == p */
// draw here...
this.clear();
for (let u of floor.users) {
pb.drawUser(u);
}
this.fill(128, 128, 128, 128);
this.noStroke();
pb.drawSensors(floor.sensors);
};
export const behavior = {
title: "Sensor Debug (P5)",
init: pb.init.bind(pb),
frameRate: 'sensors',
render: pb.render.bind(pb),
numGhosts: 1
};
export default behavior