-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsketch.js
74 lines (41 loc) · 1.37 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
let mainBranch;
let buttonList = {};
let inputHandler;
//This should Likely be done in a more sensical matter
const parse = createParser();
const parseInput = document.getElementById("parseInput");
const parseFlush = document.getElementById("parseFlush");
parseFlush.onclick = function(){
console.log(parse(parseInput.value));
mainBranch.getFromIndex(mainBranch.activeHeight + int(!mainBranch.replaceMode)).expression = parse(parseInput.value);
};
function setup() {
var canvas = createCanvas(max(windowWidth, 700), max(windowHeight-85, 700));
canvas.parent('p5canvas');
mainBranch = new Branch();
inputHandler = generateInputHandler(mainBranch)
buttonList = createButtons(inputHandler);
mainBranch.activeDepth = 0;
mainBranch.activeHeight = -1;
mainBranch.replaceMode = false;
}
function draw() {
background(25,25,40);
for(let buttonKey of Object.keys(buttonList)){
buttonList[buttonKey].draw();
}
if(frameCount % 30 == 0){
console.log('------------');
verifyTree(mainBranch, {}, 1);
//could find a better place for this, but it works now so....
resizeHandler();
}
push();
translate(0, 40);
scale(40);
mainBranch.displaySelf(true, true, buttonList, 40, inputHandler);
pop();
}
function windowResized() {
resizeHandler();
}