Browse code

box and lines

rcraig12 authored on 11/11/2018 23:08:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,67 @@
1
+require('./bootstrap');
2
+
3
+$(document).ready(function(){
4
+
5
+    drawContentBox( 100 , 100 , 'Data');
6
+    drawLine( 250 , 0 , 250 , 100);
7
+    drawLine( 250 , 400 , 250 , 1200);
8
+    drawLine( 0 , 250 , 100 , 250);
9
+    drawLine( 400 , 250 , 1400 , 250);
10
+
11
+    function drawContentBox( x , y , htmlData){
12
+
13
+    var cbox = '';
14
+    var cboxStyle = '';
15
+
16
+    cboxStyle += 'position: absolute;';
17
+    cboxStyle += 'top: ' + y + 'px;';
18
+    cboxStyle += 'left: ' + x + 'px;';
19
+    cboxStyle += 'width: 300px;';
20
+    cboxStyle += 'height: 300px';
21
+
22
+    cbox += '<div class="cbox" style="' + cboxStyle + '">' + htmlData + '</div>';
23
+
24
+    var node = $(cbox).appendTo('#app');
25
+
26
+    }
27
+
28
+    function drawLine(ax, ay, bx, by) {
29
+
30
+        if (ax > bx) {
31
+            bx = ax + bx;
32
+            ax = bx - ax;
33
+            bx = bx - ax;
34
+            by = ay + by;
35
+            ay = by - ay;
36
+            by = by - ay;
37
+        }
38
+
39
+
40
+        var angle = Math.atan((ay - by) / (bx - ax));
41
+
42
+        angle = (angle * 180 / Math.PI);
43
+        angle = -angle;
44
+
45
+        var length = Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
46
+
47
+        var style = '';
48
+        style += 'left: ' + (ax) + 'px;'
49
+        style += 'top: ' + (ay) + 'px;'
50
+        style += 'width: ' + length + 'px;'
51
+        style += 'height: 1px;'
52
+        style += 'background-color: #f60f60;'
53
+        style += 'position: absolute;'
54
+        style += 'transform: rotate(' + angle + 'deg);'
55
+        style += '-ms-transform: rotate(' + angle + 'deg);'
56
+        style += 'transform-origin: 0% 0%;'
57
+        style += '-moz-transform: rotate(' + angle + 'deg);'
58
+        style += '-moz-transform-origin: 0% 0%;'
59
+        style += '-webkit-transform: rotate(' + angle + 'deg);'
60
+        style += '-webkit-transform-origin: 0% 0%;'
61
+        style += '-o-transform: rotate(' + angle + 'deg);'
62
+        style += '-o-transform-origin: 0% 0%;'
63
+        style += 'z-index: 99;'
64
+        $('<div style="' + style + '"></div>').appendTo('#app');
65
+    }
66
+
67
+});