21
21
<div class =" node" style =" --offset-left : 3 ; --offset-top : 2 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
22
22
<div class =" primary" >
23
23
<div class =" ports" >
24
- <!-- <div class="input port">
24
+ <!-- <div class="input port" data-datatype="raster" >
25
25
<div></div>
26
26
</div> -->
27
- <div class =" output port" >
27
+ <div class =" output port" data-datatype = " raster " >
28
28
<div ></div >
29
29
</div >
30
30
</div >
35
35
<div class =" node" style =" --offset-left : 9 ; --offset-top : 2 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
36
36
<div class =" primary" >
37
37
<div class =" ports" >
38
- <div class =" input port" >
38
+ <div class =" input port" data-datatype = " raster " >
39
39
<div ></div >
40
40
</div >
41
- <div class =" output port" >
41
+ <div class =" output port" data-datatype = " raster " >
42
42
<div ></div >
43
43
</div >
44
44
</div >
48
48
<div class =" arguments" >
49
49
<div class =" argument" >
50
50
<div class =" ports" >
51
- <div class =" input port" style =" --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-vector-dim )" >
51
+ <div class =" input port" data-datatype = " raster " style =" --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-vector-dim )" >
52
52
<div ></div >
53
53
</div >
54
- <!-- <div class="output port">
54
+ <!-- <div class="output port" data-datatype="raster" >
55
55
<div></div>
56
56
</div> -->
57
57
</div >
62
62
<div class =" node" style =" --offset-left : 15 ; --offset-top : 2 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
63
63
<div class =" primary" >
64
64
<div class =" ports" >
65
- <!-- <div class="input port">
65
+ <!-- <div class="input port" data-datatype="raster" >
66
66
<div></div>
67
67
</div> -->
68
- <div class =" output port" >
68
+ <div class =" output port" data-datatype = " raster " >
69
69
<div ></div >
70
70
</div >
71
71
</div >
76
76
<div class =" node" style =" --offset-left : 21 ; --offset-top : 2 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
77
77
<div class =" primary" >
78
78
<div class =" ports" >
79
- <div class =" input port" >
79
+ <div class =" input port" data-datatype = " raster " >
80
80
<div ></div >
81
81
</div >
82
- <div class =" output port" >
82
+ <div class =" output port" data-datatype = " raster " >
83
83
<div ></div >
84
84
</div >
85
85
</div >
89
89
<div class =" arguments" >
90
90
<div class =" argument" >
91
91
<div class =" ports" >
92
- <div class =" input port" >
92
+ <div class =" input port" data-datatype = " raster " >
93
93
<div ></div >
94
94
</div >
95
- <!-- <div class="output port">
95
+ <!-- <div class="output port" data-datatype="raster" >
96
96
<div></div>
97
97
</div> -->
98
98
</div >
103
103
<div class =" node" style =" --offset-left : 2 ; --offset-top : 5 ; --data-color : var (--color-data-vector ); --data-color-dim : var (--color-data-vector-dim )" >
104
104
<div class =" primary" >
105
105
<div class =" ports" >
106
- <!-- <div class="input port">
106
+ <!-- <div class="input port" data-datatype="vector" >
107
107
<div></div>
108
108
</div> -->
109
- <div class =" output port" >
109
+ <div class =" output port" data-datatype = " vector " >
110
110
<div ></div >
111
111
</div >
112
112
</div >
117
117
<div class =" node" style =" --offset-left : 6 ; --offset-top : 7 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
118
118
<div class =" primary" >
119
119
<div class =" ports" >
120
- <!-- <div class="input port">
120
+ <!-- <div class="input port" data-datatype="raster" >
121
121
<div></div>
122
122
</div> -->
123
- <div class =" output port" >
123
+ <div class =" output port" data-datatype = " raster " >
124
124
<div ></div >
125
125
</div >
126
126
</div >
131
131
<div class =" node" style =" --offset-left : 12 ; --offset-top : 7 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
132
132
<div class =" primary" >
133
133
<div class =" ports" >
134
- <!-- <div class="input port">
134
+ <!-- <div class="input port" data-datatype="raster" >
135
135
<div></div>
136
136
</div> -->
137
- <div class =" output port" >
137
+ <div class =" output port" data-datatype = " raster " >
138
138
<div ></div >
139
139
</div >
140
140
</div >
145
145
<div class =" node" style =" --offset-left : 12 ; --offset-top : 9 ; --data-color : var (--color-data-raster ); --data-color-dim : var (--color-data-raster-dim )" >
146
146
<div class =" primary" >
147
147
<div class =" ports" >
148
- <!-- <div class="input port">
148
+ <!-- <div class="input port" data-datatype="raster" >
149
149
<div></div>
150
150
</div> -->
151
- <div class =" output port" >
151
+ <div class =" output port" data-datatype = " raster " >
152
152
<div ></div >
153
153
</div >
154
154
</div >
157
157
</div >
158
158
</div >
159
159
</div >
160
- <div class =" wires" >
160
+ <div
161
+ class =" wires"
162
+ :style =" {
163
+ transform: `scale(${transform.scale}) translate(${transform.x}px, ${transform.y}px)`,
164
+ transformOrigin: `0 0`,
165
+ }"
166
+ >
161
167
<svg ref =" wiresContainer" ></svg >
162
168
</div >
163
169
</LayoutRow >
@@ -371,15 +377,15 @@ export default defineComponent({
371
377
buildWirePathString(outputBounds : DOMRect , inputBounds : DOMRect , verticalOut : boolean , verticalIn : boolean ): string {
372
378
const containerBounds = (this .$refs .nodesContainer as HTMLElement ).getBoundingClientRect ();
373
379
374
- const outX = verticalOut ? outputBounds .x + outputBounds .width / 2 : outputBounds .x + ( outputBounds .width - 1 ) ;
375
- const outY = verticalOut ? outputBounds .y : outputBounds .y + outputBounds .height / 2 ;
376
- const outConnectorX = outX - containerBounds .x ;
377
- const outConnectorY = outY - containerBounds .y ;
380
+ const outX = verticalOut ? outputBounds .x + outputBounds .width / 2 : outputBounds .x + outputBounds .width - 1 ;
381
+ const outY = verticalOut ? outputBounds .y + 1 : outputBounds .y + outputBounds .height / 2 ;
382
+ const outConnectorX = ( outX - containerBounds .x ) / this . transform . scale ;
383
+ const outConnectorY = ( outY - containerBounds .y ) / this . transform . scale ;
378
384
379
385
const inX = verticalIn ? inputBounds .x + inputBounds .width / 2 : inputBounds .x + 1 ;
380
- const inY = verticalIn ? inputBounds .y + ( outputBounds .height + 1 ) : inputBounds .y + inputBounds .height / 2 ;
381
- const inConnectorX = inX - containerBounds .x ;
382
- const inConnectorY = inY - containerBounds .y ;
386
+ const inY = verticalIn ? inputBounds .y + inputBounds .height - 1 : inputBounds .y + inputBounds .height / 2 ;
387
+ const inConnectorX = ( inX - containerBounds .x ) / this . transform . scale ;
388
+ const inConnectorY = ( inY - containerBounds .y ) / this . transform . scale ;
383
389
// debugger;
384
390
const horizontalGap = Math .abs (outConnectorX - inConnectorX );
385
391
const verticalGap = Math .abs (outConnectorY - inConnectorY );
@@ -396,13 +402,13 @@ export default defineComponent({
396
402
verticalIn ? inConnectorX : inConnectorX - horizontalCurve
397
403
},${verticalIn ? inConnectorY + verticalCurve : inConnectorY } ${inConnectorX },${inConnectorY } ` ;
398
404
},
399
- createWirePath(outputPort : HTMLElement , inputPort : HTMLElement ): SVGPathElement {
400
- const pathString = this .buildWirePathString (outputPort .getBoundingClientRect (), inputPort .getBoundingClientRect (), true , false );
401
- const dataType = " vector " ;
405
+ createWirePath(outputPort : HTMLElement , inputPort : HTMLElement , verticalOut : boolean , verticalIn : boolean ): SVGPathElement {
406
+ const pathString = this .buildWirePathString (outputPort .getBoundingClientRect (), inputPort .getBoundingClientRect (), verticalOut , verticalIn );
407
+ const dataType = outputPort . dataset . datatype ;
402
408
403
409
const path = document .createElementNS (" http://www.w3.org/2000/svg" , " path" );
404
410
path .setAttribute (" d" , pathString );
405
- path .setAttribute (" style" , ` --data-color: var(--color-data-${dataType }); --data-color-dim: var(--color-data-${dataType }-dim) ` );
411
+ path .setAttribute (" style" , ` --data-color: var(--color-data-${dataType }); --data-color-dim: var(--color-data-${dataType }-dim) ` );
406
412
(this .$refs .wiresContainer as HTMLElement ).appendChild (path );
407
413
408
414
return path ;
@@ -430,11 +436,10 @@ export default defineComponent({
430
436
},
431
437
pointerDown(e : PointerEvent ) {
432
438
const port = (e .target as HTMLElement ).closest (" .port" ) as HTMLElement ;
433
- console .log (e .target , port );
434
439
435
440
if (port ) {
436
441
const output = port .classList .contains (" output" );
437
- const path = this .createWirePath (port , port );
442
+ const path = this .createWirePath (port , port , false , false );
438
443
this .drawing = { port , output , path };
439
444
} else {
440
445
this .panning = true ;
@@ -451,7 +456,7 @@ export default defineComponent({
451
456
const output = this .drawing .output ? port : mouse ;
452
457
const input = this .drawing .output ? mouse : port ;
453
458
454
- const pathString = this .buildWirePathString (output , input , true , false );
459
+ const pathString = this .buildWirePathString (output , input , false , false );
455
460
this .drawing .path .setAttribute (" d" , pathString );
456
461
}
457
462
},
@@ -462,9 +467,16 @@ export default defineComponent({
462
467
},
463
468
},
464
469
mounted() {
465
- const outputPort = document .querySelectorAll (" .output.port" )[4 ] as HTMLElement ;
466
- const inputPort = document .querySelectorAll (" .input.port" )[1 ] as HTMLElement ;
467
- this .createWirePath (outputPort , inputPort );
470
+ {
471
+ const outputPort = document .querySelectorAll (" .output.port" )[4 ] as HTMLElement ;
472
+ const inputPort = document .querySelectorAll (" .input.port" )[1 ] as HTMLElement ;
473
+ this .createWirePath (outputPort , inputPort , true , true );
474
+ }
475
+ {
476
+ const outputPort = document .querySelectorAll (" .output.port" )[6 ] as HTMLElement ;
477
+ const inputPort = document .querySelectorAll (" .input.port" )[3 ] as HTMLElement ;
478
+ this .createWirePath (outputPort , inputPort , true , false );
479
+ }
468
480
},
469
481
components: {
470
482
LayoutRow ,
0 commit comments