-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathline3.html
77 lines (70 loc) · 3.06 KB
/
line3.html
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
75
76
77
<html>
<head>
<!-- jquery -->
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<!-- bootstrap -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
<script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- createjs -->
<script src="../node_modules/createjs/builds/createjs-2015.11.26.min.js"></script>
<!-- vue -->
<script src="../node_modules/vue/dist/vue.min.js"></script>
</head>
<body>
<div id="app">
<canvas id="paper" width="500" height="500"></canvas>
<form class="form-inline">
<label class="sr-only">Start Point</label>
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="start point(x)" v-model="point1.x">
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="start point(y)" v-model="point1.y">
<label class="sr-only">End Point</label>
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="end point(x)" v-model="point2.x">
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="end point(y)" v-model="point2.y">
<button type="button" class="btn btn-primary mb-2" v-on:click="drawLine">Draw Blue Line</button>
</form>
<form class="form-inline">
<label class="sr-only">Start Point2</label>
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="start point2(x)" v-model="point3.x">
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="start point2(y)" v-model="point3.y">
<label class="sr-only">End Point2</label>
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="end point2(x)" v-model="point4.x">
<input type="text" class="form-control mb-2 mr-sm-2" placeholder="end point2(y)" v-model="point4.y">
<button type="button" class="btn btn-primary mb-2" v-on:click="drawLine2">Draw Red Line</button>
</form>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
point1: { x: 0, y: 0 },
point2: { x: 100, y: 100 },
point3: { x: 0, y: 100 },
point4: { x: 100, y: 200},
stage: null,
},
mounted: function () {
stage = new createjs.Stage("paper");
},
methods: {
drawLine: function () {
var line1 = new createjs.Shape();
line1.graphics.beginStroke("DeepSkyBlue");
line1.graphics.moveTo(this.point1.x, this.point1.y);
line1.graphics.lineTo(this.point2.x, this.point2.y);
line1.graphics.endStroke();
stage.addChild(line1);
stage.update();
}
,drawLine2: function () {
var line2 = new createjs.Shape();
line2.graphics.beginStroke("Red");
line2.graphics.moveTo(this.point3.x, this.point3.y);
line2.graphics.lineTo(this.point4.x, this.point4.y);
line2.graphics.endStroke();
stage.addChild(line2);
stage.update();
}
}
});
</script>
</body>