Skip to content

Commit fa6b99c

Browse files
committed
Added tool image
1 parent a9451cf commit fa6b99c

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

backend/images/driller.png

5.82 KB
Loading

backend/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
</div>
1515
<canvas id="canvas" width="1000" height="800"></canvas>
1616
<div style="display:none;">
17-
<img id="source" src="bpfactory.png"
17+
<img id="source" src="bpfactory.png"></img>
1818
</div>
19-
<div>Icons made by <a href="https://www.flaticon.com/authors/pixel-perfect" title="Pixel perfect">Pixel perfect</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>
19+
<div style="display:none;">Icons made by <a href="https://www.flaticon.com/authors/pixel-perfect" title="Pixel perfect">Pixel perfect</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>
2020
<script type="text/javascript" src='./script.js'>
2121
</script>
2222
</body>

backend/script.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const recvMargin = 100;
88
const recvRadius = 20;
99
const recvColor = "blue";
1010

11-
const toolRadius = 15;
11+
const toolRadius = 40;
1212
const toolColor = 'orange';
1313
const toolTrack = [
1414
// idle in middle
@@ -53,9 +53,12 @@ const toolTrack = [
5353
var drillingMachine = new Image();
5454
drillingMachine.src = '/images/driller.png';
5555

56+
let drillerLoaded = false;
57+
5658
drillingMachine.onload = function() {
5759
console.log("Loadded");
58-
ctx.drawImage(drillingMachine, 100, 100);
60+
drillerLoaded = true;
61+
5962
};
6063

6164

@@ -102,7 +105,14 @@ async function update() {
102105
}
103106
console.log("await: ", x, y);
104107

105-
drawDot((bw-recvMargin)*x + recvMargin, (bh-recvMargin)*y + recvMargin, toolRadius, toolColor);
108+
const toolX = (bw-recvMargin)*x + recvMargin;
109+
const toolY = (bh-recvMargin)*y + recvMargin;
110+
111+
if(drillerLoaded) {
112+
ctx.drawImage(drillingMachine, toolX-toolRadius/2, toolY-toolRadius/2, toolRadius, toolRadius);
113+
} else {
114+
drawDot(toolX, toolY, toolRadius, toolColor);
115+
}
106116
}
107117

108118
setTimeout(update, 200);

0 commit comments

Comments
 (0)