@yanqirenshi/d3.ter 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Camera", {
7
- enumerable: true,
8
- get: function get() {
9
- return _assh0le.Camera;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "Rectum", {
13
7
  enumerable: true,
14
8
  get: function get() {
@@ -21,9 +15,8 @@ var _D3Ter = _interopRequireDefault(require("./components/D3Ter.js"));
21
15
 
22
16
  var _Rectum = _interopRequireDefault(require("./js/Rectum.js"));
23
17
 
24
- var _assh0le = require("@yanqirenshi/assh0le");
25
-
26
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
19
 
20
+ // import {Camera} from '@yanqirenshi/assh0le';
28
21
  var _default = _D3Ter["default"];
29
22
  exports["default"] = _default;
@@ -15,6 +15,8 @@ var _IdentifierInstance = _interopRequireDefault(require("./IdentifierInstance.j
15
15
 
16
16
  var _AttributeInstance = _interopRequireDefault(require("./AttributeInstance.js"));
17
17
 
18
+ var _Geometry = _interopRequireDefault(require("./Geometry.js"));
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
21
 
20
22
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -70,6 +72,7 @@ var Builder = /*#__PURE__*/function (_Atman) {
70
72
  _this.size = _objectSpread({}, data.size);
71
73
  _this.type.contents = _this.entityTypeContents();
72
74
  _this.background = _this.entityBackground();
75
+ _this.geometry = new _Geometry["default"]();
73
76
  return _this;
74
77
  }
75
78
 
@@ -419,52 +422,12 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
419
422
  }
420
423
 
421
424
  _createClass(EntityTailor, [{
422
- key: "sizingType",
425
+ key: "sizing",
423
426
  value:
424
- /* **************************************************************** *
425
- * Size
427
+ /* **************************************************************** *
428
+ * Size
426
429
  * **************************************************************** */
427
- function sizingType() {
428
- var data = this.type;
429
- if (!data.contents) data.contents = '??';
430
- data.size.h = this._default.line.height + data.padding * 2;
431
- data.size.w = data.contents.length * this._default.line.font.size; // + data.padding * 2;
432
- }
433
- }, {
434
- key: "sizingName",
435
- value: function sizingName() {
436
- var data = this.name;
437
- if (!data.contents) data.contents = '????????';
438
- data.size.h = this._default.line.height + data.padding * 2;
439
- var type = this.type;
440
- data.size.w = this.size.w - this.padding * 2 - this.bar.size.header - type.size.w;
441
- }
442
- }, {
443
- key: "sizingIdentifiers",
444
- value: function sizingIdentifiers() {
445
- var data = this.identifiers;
446
- var padding = this.padding;
447
- data.size.w = (this.size.w - padding * 2) / 2 - this.bar.size.contents / 2;
448
- data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
449
- }
450
- }, {
451
- key: "sizingAttributes",
452
- value: function sizingAttributes() {
453
- var data = this.attributes;
454
- var padding = this.padding;
455
- data.size.w = (this.size.w - this.padding * 2) / 2 - this.bar.size.contents / 2;
456
- data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
457
- }
458
- }, {
459
- key: "sizingContentsArea",
460
- value: function sizingContentsArea() {
461
- var id_h = this.identifiers.size.h;
462
- var attr_h = this.attributes.size.h;
463
- if (id_h > attr_h) this.attributes.size.h = id_h;else this.identifiers.size.h = attr_h;
464
- }
465
- }, {
466
- key: "sizing",
467
- value: function sizing() {
430
+ function sizing() {
468
431
  this.sizingType();
469
432
  this.sizingName();
470
433
  this.sizingIdentifiers();
@@ -499,10 +462,53 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
499
462
 
500
463
  return this;
501
464
  }
502
- /* **************************************************************** *
503
- * Position
465
+ /* **************************************************************** *
466
+ * Position
504
467
  * **************************************************************** */
505
468
 
469
+ }, {
470
+ key: "positioning",
471
+ value: function positioning() {
472
+ this.positioningEntity(this);
473
+ return this;
474
+ }
475
+ /* **************************************************************** *
476
+ * Entity
477
+ * **************************************************************** */
478
+
479
+ }, {
480
+ key: "positioningEntity",
481
+ value: function positioningEntity(entity, entities) {
482
+ this.positioningName();
483
+ this.positioningType();
484
+ this.positioningIdentifiers();
485
+ this.positioningAttributes();
486
+ this.positioningPorts();
487
+ }
488
+ /* **************************************************************** *
489
+ * Contents Area
490
+ * **************************************************************** */
491
+
492
+ }, {
493
+ key: "sizingContentsArea",
494
+ value: function sizingContentsArea() {
495
+ var id_h = this.identifiers.size.h;
496
+ var attr_h = this.attributes.size.h;
497
+ if (id_h > attr_h) this.attributes.size.h = id_h;else this.identifiers.size.h = attr_h;
498
+ }
499
+ /* **************************************************************** *
500
+ * Name
501
+ * **************************************************************** */
502
+
503
+ }, {
504
+ key: "sizingName",
505
+ value: function sizingName() {
506
+ var data = this.name;
507
+ if (!data.contents) data.contents = '????????';
508
+ data.size.h = this._default.line.height + data.padding * 2;
509
+ var type = this.type;
510
+ data.size.w = this.size.w <= 0 ? 0 : this.size.w - this.padding * 2 - this.bar.size.header - type.size.w;
511
+ }
506
512
  }, {
507
513
  key: "positioningName",
508
514
  value: function positioningName() {
@@ -511,6 +517,18 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
511
517
  d.position.x = entity.padding;
512
518
  d.position.y = entity.padding;
513
519
  }
520
+ /* **************************************************************** *
521
+ * Type
522
+ * **************************************************************** */
523
+
524
+ }, {
525
+ key: "sizingType",
526
+ value: function sizingType() {
527
+ var data = this.type;
528
+ if (!data.contents) data.contents = '??';
529
+ data.size.h = this._default.line.height + data.padding * 2;
530
+ data.size.w = data.contents.length * this._default.line.font.size; // + data.padding * 2;
531
+ }
514
532
  }, {
515
533
  key: "positioningType",
516
534
  value: function positioningType() {
@@ -520,6 +538,10 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
520
538
  d.position.x = entity.padding + entity.name.size.w + bar;
521
539
  d.position.y = entity.padding;
522
540
  }
541
+ /* **************************************************************** *
542
+ * ColumnItems
543
+ * **************************************************************** */
544
+
523
545
  }, {
524
546
  key: "positioningColumnItems",
525
547
  value: function positioningColumnItems(d) {
@@ -545,6 +567,18 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
545
567
  _iterator3.f();
546
568
  }
547
569
  }
570
+ /* **************************************************************** *
571
+ * Identifiers
572
+ * **************************************************************** */
573
+
574
+ }, {
575
+ key: "sizingIdentifiers",
576
+ value: function sizingIdentifiers() {
577
+ var data = this.identifiers;
578
+ var padding = this.padding;
579
+ data.size.w = this.size.w <= 0 ? 0 : (this.size.w - padding * 2) / 2 - this.bar.size.contents / 2;
580
+ data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
581
+ }
548
582
  }, {
549
583
  key: "positioningIdentifiers",
550
584
  value: function positioningIdentifiers() {
@@ -555,6 +589,18 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
555
589
  d.position.y = entity.padding + entity.name.size.h + bar;
556
590
  this.positioningColumnItems(d);
557
591
  }
592
+ /* **************************************************************** *
593
+ * Attributes
594
+ * **************************************************************** */
595
+
596
+ }, {
597
+ key: "sizingAttributes",
598
+ value: function sizingAttributes() {
599
+ var data = this.attributes;
600
+ var padding = this.padding;
601
+ data.size.w = this.size.w <= 0 ? 0 : (this.size.w - this.padding * 2) / 2 - this.bar.size.contents / 2;
602
+ data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
603
+ }
558
604
  }, {
559
605
  key: "positioningAttributes",
560
606
  value: function positioningAttributes() {
@@ -566,196 +612,39 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
566
612
  d.position.y = entity.padding + entity.name.size.h + bar_horizontal;
567
613
  this.positioningColumnItems(d);
568
614
  }
569
- }, {
570
- key: "deg2rad",
571
- value: function deg2rad(degree) {
572
- return degree * (Math.PI / 180);
573
- }
574
- }, {
575
- key: "getPortLineLength",
576
- value: function getPortLineLength(entity) {
577
- var max_length = Math.floor(Math.sqrt(entity.size.w * entity.size.w + entity.size.h * entity.size.h));
578
- return 0.8 * max_length;
579
- }
580
- }, {
581
- key: "getPortLineFrom",
582
- value: function getPortLineFrom(entity) {
583
- return {
584
- x: Math.floor(entity.size.w / 2),
585
- y: Math.floor(entity.size.h / 2)
586
- };
587
- }
588
- }, {
589
- key: "makePortLine",
590
- value: function makePortLine(entity, port) {
591
- var out = {
592
- from: {
593
- x: 0,
594
- y: 0
595
- },
596
- to: {
597
- x: 0,
598
- y: 0
599
- }
600
- };
601
- var from = this.getPortLineFrom(entity);
602
- out.from.x = from.x;
603
- out.from.y = from.y;
604
- var x = 0;
605
- var y = this.getPortLineLength(entity);
606
- var degree = port.position_degree();
607
- var radian = this.deg2rad(degree);
608
- var cos = Math.cos(radian);
609
- var sin = Math.sin(radian);
610
- out.to.x = Math.floor(x * cos - y * sin);
611
- out.to.y = Math.floor(x * sin + y * cos);
612
- out.to.x += out.from.x;
613
- out.to.y += out.from.y;
614
- port._from = out.from;
615
- port._to = out.to;
616
- return out;
617
- }
618
- }, {
619
- key: "isCorss",
620
- value: function isCorss(A, B, C, D) {
621
- // 二つの線分の交差チェック
622
- // https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
623
- var ACx = C.x - A.x;
624
- var ACy = C.y - A.y;
625
- var BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
626
- if (BUNBO === 0) return false;
627
- var r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
628
- var s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
629
- return 0 <= r && r <= 1 && 0 <= s && s <= 1;
630
- }
631
- }, {
632
- key: "getCrossPointCore",
633
- value: function getCrossPointCore(line, line_port, port) {
634
- // 2直線の交点を求める公式
635
- var out = {
636
- x: 0,
637
- y: 0
638
- };
639
- var A = line.from;
640
- var B = line.to;
641
- var C = line_port.from;
642
- var D = line_port.to;
643
- var bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
644
- if (!this.isCorss(A, B, C, D)) return null; // 二つの線分の交点を算出する。
645
- // http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
646
-
647
- var d1, d2;
648
- d1 = C.y * D.x - C.x * D.y;
649
- d2 = A.y * B.x - A.x * B.y;
650
- out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
651
- out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
652
- return out;
653
- }
654
- }, {
655
- key: "getCrossPoint",
656
- value: function getCrossPoint(lines, line_port, port) {
657
- var _iterator4 = _createForOfIteratorHelper(lines),
658
- _step4;
659
-
660
- try {
661
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
662
- var line = _step4.value;
663
- var point = this.getCrossPointCore(line, line_port, port);
664
- if (point) return point;
665
- }
666
- } catch (err) {
667
- _iterator4.e(err);
668
- } finally {
669
- _iterator4.f();
670
- }
615
+ /* **************************************************************** *
616
+ * Port
617
+ * **************************************************************** */
671
618
 
672
- return null;
673
- }
674
- }, {
675
- key: "getEntityLines",
676
- value: function getEntityLines(entity) {
677
- var port_r = 4;
678
- var margin = entity.margin + port_r;
679
- var w = entity.size.w;
680
- var h = entity.size.h;
681
- var top_left = {
682
- x: 0 - margin,
683
- y: 0 - margin
684
- };
685
- var top_right = {
686
- x: w + margin,
687
- y: 0 - margin
688
- };
689
- var bottom_rigth = {
690
- x: w + margin,
691
- y: h + margin
692
- };
693
- var bottom_left = {
694
- x: 0 - margin,
695
- y: h + margin
696
- };
697
- return [{
698
- from: top_left,
699
- to: top_right
700
- }, {
701
- from: top_right,
702
- to: bottom_rigth
703
- }, {
704
- from: bottom_rigth,
705
- to: bottom_left
706
- }, {
707
- from: bottom_left,
708
- to: top_left
709
- }];
710
- }
711
619
  }, {
712
620
  key: "positioningPort",
713
621
  value: function positioningPort(port) {
714
622
  var entity = this;
715
- var line_port = this.makePortLine(entity, port);
716
- var lines_entity = this.getEntityLines(entity);
717
- var point = this.getCrossPoint(lines_entity, line_port, port);
718
- if (!point) point = {
719
- x: 0,
720
- y: 0
721
- };
722
- port.position = point;
723
- return port;
623
+ var line_port = this.geometry.getPortLine(port, entity);
624
+ var lines_entity = this.geometry.getFourSideLines(entity);
625
+ var point = this.geometry.getCrossPoint(lines_entity, line_port);
626
+ port.position = point.point;
627
+ return port.point;
724
628
  }
725
629
  }, {
726
630
  key: "positioningPorts",
727
631
  value: function positioningPorts() {
728
632
  var ports = this.ports.items.list;
729
633
 
730
- var _iterator5 = _createForOfIteratorHelper(ports),
731
- _step5;
634
+ var _iterator4 = _createForOfIteratorHelper(ports),
635
+ _step4;
732
636
 
733
637
  try {
734
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
735
- var port = _step5.value;
638
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
639
+ var port = _step4.value;
736
640
  this.positioningPort(port);
737
641
  }
738
642
  } catch (err) {
739
- _iterator5.e(err);
643
+ _iterator4.e(err);
740
644
  } finally {
741
- _iterator5.f();
645
+ _iterator4.f();
742
646
  }
743
647
  }
744
- }, {
745
- key: "positioningEntity",
746
- value: function positioningEntity(entity, entities) {
747
- this.positioningName();
748
- this.positioningType();
749
- this.positioningIdentifiers();
750
- this.positioningAttributes();
751
- this.positioningPorts();
752
- }
753
- }, {
754
- key: "positioning",
755
- value: function positioning() {
756
- this.positioningEntity(this);
757
- return this;
758
- }
759
648
  }]);
760
649
 
761
650
  return EntityTailor;
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
9
+
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
13
+
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
16
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
+
18
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
+
20
+ // https://yanqirenshi.github.io/D3.Sketch/dist/edge/Drawer.js
21
+
22
+ /**
23
+ * 幾何学計算するための Drawer です。
24
+ *
25
+ * @example
26
+ * let drawer = new DrawerHierarchy();
27
+ */
28
+ var Geometry = /*#__PURE__*/function () {
29
+ function Geometry() {
30
+ _classCallCheck(this, Geometry);
31
+ }
32
+
33
+ _createClass(Geometry, [{
34
+ key: "deg2rad",
35
+ value: ///// ////////////////////////////////////////////////////////////////
36
+ ///// Utilities
37
+ ///// ////////////////////////////////////////////////////////////////
38
+ function deg2rad(degree) {
39
+ return degree * (Math.PI / 180);
40
+ } ///// ////////////////////////////////////////////////////////////////
41
+ ///// Rect
42
+ ///// ////////////////////////////////////////////////////////////////
43
+
44
+ }, {
45
+ key: "getFourSideLines",
46
+ value: function getFourSideLines(rect) {
47
+ var x = 0; //rect.position.x;
48
+
49
+ var y = 0; //rect.position.y;
50
+
51
+ var w = rect.size.w;
52
+ var h = rect.size.h;
53
+ var port_r = 4; // let margin = 33 + port_r;
54
+
55
+ var margin = 11 + port_r;
56
+ var top_left = {
57
+ x: x - margin,
58
+ y: y - margin
59
+ };
60
+ var top_right = {
61
+ x: x + w + margin,
62
+ y: y - margin
63
+ };
64
+ var bottom_rigth = {
65
+ x: x + w + margin,
66
+ y: y + h + margin
67
+ };
68
+ var bottom_left = {
69
+ x: x - margin,
70
+ y: y + h + margin
71
+ };
72
+ return [{
73
+ code: 'top',
74
+ from: top_left,
75
+ to: top_right
76
+ }, {
77
+ code: 'right',
78
+ from: top_right,
79
+ to: bottom_rigth
80
+ }, {
81
+ code: 'bottom',
82
+ from: bottom_rigth,
83
+ to: bottom_left
84
+ }, {
85
+ code: 'left',
86
+ from: bottom_left,
87
+ to: top_left
88
+ }];
89
+ } ///// ////////////////////////////////////////////////////////////////
90
+ ///// Rect
91
+ ///// ////////////////////////////////////////////////////////////////
92
+
93
+ }, {
94
+ key: "getPortLineFrom",
95
+ value: function getPortLineFrom(rect) {
96
+ return {
97
+ x: Math.floor(rect.size.w / 2),
98
+ y: Math.floor(rect.size.h / 2)
99
+ };
100
+ }
101
+ }, {
102
+ key: "getPortLineToPoint",
103
+ value: function getPortLineToPoint(node) {
104
+ var w = node.size.w;
105
+ var h = node.size.h;
106
+ return {
107
+ x: 0,
108
+ y: Math.floor(Math.sqrt(w * w + h * h))
109
+ };
110
+ }
111
+ }, {
112
+ key: "getPortLineTo",
113
+ value: function getPortLineTo(degree, node) {
114
+ var point = this.getPortLineToPoint(node);
115
+ var x = point.x;
116
+ var y = point.y;
117
+ var degree_tmp;
118
+ if (degree === 0) degree_tmp = degree;else if (!degree) degree_tmp = 90;else degree_tmp = degree % 360;
119
+ var radian = this.deg2rad(degree_tmp);
120
+ var cos = Math.cos(radian);
121
+ var sin = Math.sin(radian);
122
+ return {
123
+ x: Math.floor(x * cos - y * sin),
124
+ y: Math.floor(x * sin + y * cos)
125
+ };
126
+ }
127
+ }, {
128
+ key: "getPortLine",
129
+ value: function getPortLine(port, rect) {
130
+ // degree,
131
+ var from = this.getPortLineFrom(rect);
132
+ var to = this.getPortLineTo(port.degree, rect);
133
+ return {
134
+ from: {
135
+ x: from.x,
136
+ y: from.y
137
+ },
138
+ to: {
139
+ x: to.x + from.x,
140
+ y: to.y + from.y
141
+ }
142
+ };
143
+ } ///// ////////////////////////////////////////////////////////////////
144
+ ///// Cross Point of two lines
145
+ ///// ////////////////////////////////////////////////////////////////
146
+
147
+ }, {
148
+ key: "isCorss",
149
+ value: function isCorss(A, B, C, D) {
150
+ // 二つの線分の交差チェック
151
+ // https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
152
+ var ACx = C.x - A.x;
153
+ var ACy = C.y - A.y;
154
+ var BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
155
+ if (BUNBO === 0) return false;
156
+ var r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
157
+ var s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
158
+ return 0 <= r && r <= 1 && 0 <= s && s <= 1;
159
+ } // 2直線の交点を求める。(具)
160
+
161
+ }, {
162
+ key: "getCrossPointCore",
163
+ value: function getCrossPointCore(line, line_port) {
164
+ var out = {
165
+ x: 0,
166
+ y: 0
167
+ };
168
+ var A = line.from;
169
+ var B = line.to;
170
+ var C = line_port.from;
171
+ var D = line_port.to;
172
+ var bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
173
+ if (!this.isCorss(A, B, C, D)) return null; // 二つの線分の交点を算出する。
174
+ // http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
175
+
176
+ var d1, d2;
177
+ d1 = C.y * D.x - C.x * D.y;
178
+ d2 = A.y * B.x - A.x * B.y;
179
+ out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
180
+ out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
181
+ return out;
182
+ } // 2直線の交点を求める。
183
+
184
+ }, {
185
+ key: "getCrossPoint",
186
+ value: function getCrossPoint(lines, line_port) {
187
+ var _iterator = _createForOfIteratorHelper(lines),
188
+ _step;
189
+
190
+ try {
191
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
192
+ var line = _step.value;
193
+ var point = this.getCrossPointCore(line, line_port);
194
+ if (point) return {
195
+ point: point,
196
+ target: line.code
197
+ };
198
+ }
199
+ } catch (err) {
200
+ _iterator.e(err);
201
+ } finally {
202
+ _iterator.f();
203
+ }
204
+
205
+ return null;
206
+ }
207
+ }]);
208
+
209
+ return Geometry;
210
+ }();
211
+
212
+ exports["default"] = Geometry;