-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsketch.js
84 lines (61 loc) · 1.65 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
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
let graph;
let input;
let button;
let transactionAmountSlider;
let transcationSizeFilter;
let globalTranslation;
let zoomScale = 1;
const sidebarMargin = 10;
function setup() {
createCanvas(windowWidth, windowHeight);
input = createInput("");
input.position(10,10);
button = createButton("Submit");
button.position(input.width+10,10);
button.mousePressed(handleSubmission);
globalTranslation = createVector(width/2,height/2);
graph = new Graph();
}
function draw() {
background(30);
// circle(width/2,height/2,10000);
if(graph.transactionsLoaded == true) {
push();
// scale(zoomScale);
// translate(globalTranslation);
graph.render();
pop();
}
}
function handleSubmission() {
if(input.value().slice(0,2) != "0x") {
window.alert("Please give an address or a contract");
} else {
//check if there is already a graph active
if(graph.transactionsLoaded == true) {
window.alert(`There is already a graph loaded at address: ${graph.createShortHand(graph.address)}`);
return;
}
const address = input.value().trim()
graph.address = address;
//Fetch the accounts history here
graph.requestAccountHistory(address);
// shortHand = createShortHand(address);
}
}
function mousePressed() {
if(graph.transactionsLoaded == true) {
graph.selectNode(globalTranslation);
graph.selectPanel();
} else {
return;
}
}
//Moved controller.js code out into the app file
// function mouseDragged(e) {
// globalTranslation.x += e.movementX;
// globalTranslation.y += e.movementY;
// }
// function mouseWheel(e) {
// zoomScale -= e.delta/1000;
// }