@elicdavis/node-flow 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@elicdavis/node-flow",
3
3
  "description": "build node graphs",
4
4
  "author": "Eli C Davis",
5
- "version": "0.1.2",
5
+ "version": "0.1.3",
6
6
  "license": "MIT",
7
7
  "keywords": [
8
8
  "nodes",
@@ -17,6 +17,7 @@ export enum VerticalAlign {
17
17
  export interface TextElementStyling extends RenderElementBaseStyling {
18
18
  Align?: TextAlign
19
19
  VerticalAlign?: VerticalAlign
20
+ LineHeight?: number
20
21
  }
21
22
 
22
23
  export class TextElement extends RenderElementBase {
@@ -26,11 +27,14 @@ export class TextElement extends RenderElementBase {
26
27
 
27
28
  #verticalAlign: VerticalAlign;
28
29
 
30
+ #lineHeight: number;
31
+
29
32
  constructor(text: Text, styling?: TextElementStyling) {
30
33
  super(styling);
31
34
  this.#text = text;
32
35
  this.#align = styling?.Align ?? TextAlign.Left;
33
36
  this.#verticalAlign = styling?.VerticalAlign ?? VerticalAlign.Top;
37
+ this.#lineHeight = styling?.LineHeight ?? 1;
34
38
  }
35
39
 
36
40
  doRender(ctx: CanvasRenderingContext2D, position: Vector2, graphScale: number, scaledFillableSpace: Vector2): void {
@@ -87,28 +91,24 @@ export class TextElement extends RenderElementBase {
87
91
  for (let i = 0; i < eles.length; i++) {
88
92
  eles[i].render(ctx, graphScale, justifiedPosition);
89
93
  eles[i].size(ctx, 1, tempSize)
90
- justifiedPosition.y += tempSize.y
94
+ justifiedPosition.y += this.#text.style().getSize() * this.#lineHeight
91
95
  }
92
96
  }
93
97
  }
94
98
 
95
99
  calcSize(ctx: CanvasRenderingContext2D, out: Vector2, limitations: Vector2): void {
96
-
97
100
  if (limitations.x <= 0) {
98
101
  this.#text.size(ctx, 1, out);
99
102
  return;
100
103
  }
101
104
 
102
105
  const eles = this.#text.breakIntoLines(ctx, limitations.x);
103
-
104
106
  const tempSize = { x: 0, y: 0 };
105
107
  out.x = 0;
106
- out.y = 0;
108
+ out.y = this.#text.style().getSize() * eles.length * this.#lineHeight;
107
109
  for (let i = 0; i < eles.length; i++) {
108
110
  eles[i].size(ctx, 1, tempSize)
109
111
  out.x = Math.max(tempSize.x, out.x);
110
- out.y += tempSize.y
111
112
  }
112
-
113
113
  }
114
114
  }
package/src/port.ts CHANGED
@@ -126,8 +126,9 @@ export class Port {
126
126
  new Text(description, { color: "white", style: FontStyle.Italic }),
127
127
  {
128
128
  Align: TextAlign.Center,
129
- Padding: { Top: 8 },
130
- MaxWidth: 300
129
+ Padding: { Top: 16 },
130
+ MaxWidth: 400,
131
+ LineHeight: 1.5
131
132
  }
132
133
  ));
133
134
  }