-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
51 lines (42 loc) · 1.07 KB
/
sketch.js
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
// Create WebSocket connection.
const socket = new WebSocket('ws://localhost:9002');
// Connection opened
socket.addEventListener('open', function (event) {
socket.send('Hello Server!');
});
// Listen for messages
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
});
function setup() {
createCanvas(1200, 400);
//createCanvas(displayWidth*pixelDensity(), displayHeight*pixelDensity() );
frameRate(5);
}
function draw() {
background(255);
angleMode(DEGREES);
stroke(0);
fill(255);
strokeWeight(2);
VariablyThickLine(createVector(50, height/2), createVector(width-50, height/2), [50]);
drawCircle(createVector(350, height/2), 100);
drawCircle(createVector(850, height/2), 100);
fill(0, 255, 0);
drawCircle(createVector(350, height/2), 50);
drawCircle(createVector(850, height/2), 50);
//noLoop();
}
function SendMouse() {
socket.send("mouse");
}
function say(sentence) {
socket.send(sentence);
return 0;
}
function keyPressed() {
if (key == "s") {
print("YO!");
SendMouse();
}
}