-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp0.js
More file actions
60 lines (52 loc) · 1.36 KB
/
p0.js
File metadata and controls
60 lines (52 loc) · 1.36 KB
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
var socket;
var grid;
var colorText;
var colorRange;
var gray = 125;
function setup(){
socket = io.connect('https://fathomless-temple-7308.herokuapp.com/');
createCanvas(windowWidth,windowHeight);
background(255);
frameRate(60);
socket.on(
'mouse',
function(data){
fill(data.z, 100);
noStroke();
ellipse(data.x,data.y,2,2);
}
)
}
function mouseDragged(){
fill(gray, 100);
var data = {
x : mouseX,
y : mouseY,
z : gray
}
socket.emit('mouse', data);
noStroke();
ellipse(mouseX,mouseY,2,2);
}
function colorStatus (otherInput,colorValue){
otherInput.value = colorValue;
gray = parseInt(colorValue);
}
function saveNewDrawing(){
var name = new Date();
saveCanvas(canvas,"drawing name",'png');
}
window.onbeforeunload = function (){
return 'Leaving the page will erase all work.'
}
$(document).ready(function(){
colorRange = document.getElementById('color-range');
colorText = document.getElementById('color-text');
grid = document.getElementById('grid');
document.onkeyup = function(e){
var kC = e.keyCode;
if (kC > 36 && kC < 41) colorRange.focus();
if(kC == "13") saveNewDrawing();
if(kC == "32") grid.style.display = grid.style.display == "none" ? "block" : "none";
}
})