-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.js
67 lines (57 loc) · 1014 Bytes
/
node.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
class Node {
constructor(x, y, size){
this.size = size;
this.x = x;
this.y = y;
this.text = 'q_'+nodes.length;
this.accepting = false;
this.errorHighlight = false;
}
draw(highlight, current){
if(highlight){
stroke(0, 0, 255);
}else{
stroke(0);
}
if(current){
fill(122, 207, 207);
}else{
fill(255);
}
if(this.errorHighlight){
fill(209, 88, 88);
}
strokeWeight(lineStrength);
ellipse(this.x, this.y, this.size);
if(this.accepting){
ellipse(this.x, this.y, this.size*0.85);
}
noStroke();
if(highlight){
fill(0, 0, 255);
}else{
fill(0);
}
textAlign(CENTER, CENTER);
textSize(fontSize);
textFont('Times New Roman');
let displayText = prettyText(this.text);
if(highlight){
displayText += '|';
}
text(displayText, this.x, this.y);
}
}
class FloatingNode {
constructor(x, y){
this.x = x;
this.y = y;
this.size = 0;
}
}
class TrappingNode {
constructor(){
this.accepting = false;
this.trapping = true;
}
}