Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 45fd484

Browse files
authored
upadate example to show (random in all direction, start in the middle)
1 parent f741203 commit 45fd484

File tree

1 file changed

+7
-56
lines changed

1 file changed

+7
-56
lines changed

gcode/main.js

+7-56
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,16 @@ import GcodeAPI from "./src/API/GcodeApi/GcodeAPI_main/GcodeAPI";
44
import G0 from "./src/API/GcodeApi/Gcommands/G/G0";
55
import Gcss from "./src/API/GcodeApi/Gsimulator/Gcss/Gcss.js";
66

7-
let a = new G0({});
7+
let a = new G0({x: 250, y: 250});
88

9-
for (let i = 0; i < 3; i++) {
10-
a.moveTo({ left: 10, top: 30 });
11-
}
12-
13-
for (let i = 0; i < 3; i++) {
14-
a.moveTo({ left: 100 });
15-
}
16-
17-
for (let i = 0; i < 3; i++) {
18-
a.moveTo({
19-
bottom: 50,
20-
});
21-
}
9+
for (let i = 0; i < 20; i++) {
10+
let x = ["left", "right"][Math.round(Math.random())];
11+
let y = ["top", "bottom"][Math.round(Math.random())];
2212

23-
for (let i = 0; i < 3; i++) {
2413
a.moveTo({
25-
right: 100,
26-
});
27-
}
28-
29-
for (let i = 0; i < 3; i++) {
30-
a.moveTo({
31-
bottom: 50,
32-
right: 50,
33-
});
34-
}
35-
36-
for (let i = 0; i < 3; i++) {
37-
a.moveTo({
38-
top: 50,
39-
right: 20,
40-
});
41-
}
42-
43-
for (let i = 0; i < 4; i++) {
44-
a.moveTo({ left: 50 });
45-
}
46-
47-
for (let i = 0; i < 3; i++) {
48-
a.moveTo({ bottom: 30, left: 50 });
14+
[x]: Math.random() * 50,
15+
[y]: Math.random() * 50
16+
})
4917
}
5018

5119
let g = new Gcss({
@@ -58,20 +26,3 @@ g.generate();
5826

5927
const t1 = performance.now();
6028
console.log(`Call to doSomething took ${t1 - t0} milliseconds.`);
61-
// console.table(GcodeAPI.array);
62-
63-
// let btn = document.querySelector("#btn")
64-
65-
// btn.addEventListener("click", btnGenerate, { once: true });
66-
67-
// function btnGenerate() {
68-
// let g = new Gcss({
69-
// width: 500,
70-
// height: 500,
71-
// parentHtmlContainer: document.querySelector("section"),
72-
// });
73-
74-
// g.generate();
75-
76-
// btn.disabled = true;
77-
// }

0 commit comments

Comments
 (0)