-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
45 lines (42 loc) · 1.58 KB
/
index.html
File metadata and controls
45 lines (42 loc) · 1.58 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D previewer</title>
<style type="text/css">
input {
max-width: 30px;
}
</style>
</head>
<body>
<textarea id="gcode" name="" cols="30" rows="10"></textarea>
<br />
<label for="width">Width:<input id="width" type="text" value="300" /></label>
<label for="height">Height:<input id="height" type="text" value="300" /></label>
<br />
<button id="test">Test</button>
<button id="toImage">Image</button>
<br />
<canvas id="canvas" width="600" height="400"></canvas>
<img id="image" />
<!-- <script src="gcodetogeometry.min.js"></script> -->
<!-- <script src="gcode2dviewer.js"></script> -->
<script src="gcode2dviewer.min.js"></script>
<script type="text/javascript">
document.getElementById("test").onclick = function() {
var code = document.getElementById("gcode").value;
var colors = { G1 : '#000000', G2G3 : "#000000" };
GCode2DViewer.preview(code, colors, document.getElementById("canvas"));
};
document.getElementById("toImage").onclick = function() {
var code = document.getElementById("gcode").value;
var colors = { G1 : '#000000', G2G3 : "#000000" };
var img = document.getElementById("image");
var width = document.getElementById("width").value;
var height = document.getElementById("height").value;
img.src = GCode2DViewer.getImage(code, colors, width, height);
};
</script>
</body>
</html>