@swirly/renderer 0.21.0 → 0.22.0
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/LICENSE +1 -1
- package/README.md +4 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/arrow.d.ts +1 -1
- package/dist/arrow.js +14 -14
- package/dist/arrow.js.map +1 -1
- package/dist/decoration/barrier.d.ts +2 -2
- package/dist/decoration/barrier.js +8 -8
- package/dist/decoration/barrier.js.map +1 -1
- package/dist/decoration/index.d.ts +2 -2
- package/dist/decoration/index.js +3 -3
- package/dist/decoration/index.js.map +1 -1
- package/dist/decoration/range.d.ts +2 -2
- package/dist/decoration/range.js +7 -7
- package/dist/decoration/range.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/message/complete.d.ts +2 -2
- package/dist/message/complete.js +10 -10
- package/dist/message/complete.js.map +1 -1
- package/dist/message/error.d.ts +2 -2
- package/dist/message/error.js +12 -12
- package/dist/message/error.js.map +1 -1
- package/dist/message/index.d.ts +2 -2
- package/dist/message/index.js +2 -2
- package/dist/message/index.js.map +1 -1
- package/dist/message/non-stream.d.ts +2 -2
- package/dist/message/non-stream.js +5 -9
- package/dist/message/non-stream.js.map +1 -1
- package/dist/message/scalar.d.ts +2 -2
- package/dist/message/scalar.js +21 -21
- package/dist/message/scalar.js.map +1 -1
- package/dist/message/stream.d.ts +2 -2
- package/dist/message/stream.js +7 -7
- package/dist/message/stream.js.map +1 -1
- package/dist/operator.d.ts +2 -2
- package/dist/operator.js +40 -40
- package/dist/operator.js.map +1 -1
- package/dist/stream/core.d.ts +1 -1
- package/dist/stream/core.js +2 -2
- package/dist/stream/core.js.map +1 -1
- package/dist/stream/factory.d.ts +2 -2
- package/dist/stream/factory.js +18 -24
- package/dist/stream/factory.js.map +1 -1
- package/dist/stream/full.d.ts +2 -2
- package/dist/stream/full.js +14 -14
- package/dist/stream/full.js.map +1 -1
- package/dist/types.d.ts +13 -13
- package/dist/util/degrees-to-radians.js.map +1 -1
- package/dist/util/geometry.d.ts +1 -1
- package/dist/util/geometry.js +6 -6
- package/dist/util/geometry.js.map +1 -1
- package/dist/util/hex-to-dec.js +2 -2
- package/dist/util/hex-to-dec.js.map +1 -1
- package/dist/util/merge-styles.d.ts +1 -1
- package/dist/util/merge-styles.js.map +1 -1
- package/dist/util/notification-kind.js +4 -4
- package/dist/util/notification-kind.js.map +1 -1
- package/dist/util/string-to-color.d.ts +1 -1
- package/dist/util/string-to-color.js +3 -3
- package/dist/util/string-to-color.js.map +1 -1
- package/dist/util/svg-xml.d.ts +1 -1
- package/dist/util/svg-xml.js +8 -8
- package/dist/util/svg-xml.js.map +1 -1
- package/dist/util/transform.js +3 -3
- package/dist/util/transform.js.map +1 -1
- package/package.json +20 -20
- package/src/arrow.ts +34 -35
- package/src/decoration/barrier.ts +20 -24
- package/src/decoration/index.ts +11 -11
- package/src/decoration/range.ts +20 -27
- package/src/index.ts +55 -68
- package/src/message/complete.ts +24 -28
- package/src/message/error.ts +27 -27
- package/src/message/index.ts +8 -12
- package/src/message/non-stream.ts +12 -20
- package/src/message/scalar.ts +44 -52
- package/src/message/stream.ts +27 -40
- package/src/operator.ts +104 -120
- package/src/stream/core.ts +3 -3
- package/src/stream/factory.ts +86 -102
- package/src/stream/full.ts +34 -37
- package/src/types.ts +39 -39
- package/src/util/degrees-to-radians.ts +1 -2
- package/src/util/geometry.ts +29 -42
- package/src/util/hex-to-dec.ts +8 -8
- package/src/util/merge-styles.ts +9 -11
- package/src/util/notification-kind.ts +8 -8
- package/src/util/string-to-color.ts +10 -10
- package/src/util/svg-xml.ts +20 -23
- package/src/util/transform.ts +11 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/stream/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/stream/factory.ts"],"names":[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AG,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/stream/full.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StreamSpecification } from
|
|
2
|
-
import { RendererContext, RendererResult } from
|
|
1
|
+
import { StreamSpecification } from "@swirly/types";
|
|
2
|
+
import { RendererContext, RendererResult } from "../types.js";
|
|
3
3
|
export declare const renderStream: (ctx: RendererContext, stream: StreamSpecification) => RendererResult;
|
package/dist/stream/full.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { mergeStyles } from
|
|
2
|
-
import { createSvgElement } from
|
|
3
|
-
import { translate } from
|
|
4
|
-
import { renderStreamBase } from
|
|
1
|
+
import { mergeStyles } from "../util/merge-styles.js";
|
|
2
|
+
import { createSvgElement } from "../util/svg-xml.js";
|
|
3
|
+
import { translate } from "../util/transform.js";
|
|
4
|
+
import { renderStreamBase } from "./core.js";
|
|
5
5
|
export const renderStream = (ctx, stream) => {
|
|
6
6
|
const { document, styles, streamHeight, streamTitleEnabled } = ctx;
|
|
7
|
-
const s = mergeStyles(styles, stream.styles,
|
|
7
|
+
const s = mergeStyles(styles, stream.styles, "stream_");
|
|
8
8
|
const renderStreamResult = renderStreamBase(ctx, stream, false, false);
|
|
9
9
|
const { element: $streamGroup, bbox } = renderStreamResult;
|
|
10
10
|
if (stream.frame != null && stream.frame > 0) {
|
|
@@ -16,17 +16,17 @@ export const renderStream = (ctx, stream) => {
|
|
|
16
16
|
if (!streamTitleEnabled) {
|
|
17
17
|
return renderStreamResult;
|
|
18
18
|
}
|
|
19
|
-
const $outerGroup = createSvgElement(document,
|
|
20
|
-
const title = typeof stream.title ===
|
|
21
|
-
$outerGroup.appendChild(createSvgElement(document,
|
|
19
|
+
const $outerGroup = createSvgElement(document, "g");
|
|
20
|
+
const title = typeof stream.title === "string" ? stream.title : "";
|
|
21
|
+
$outerGroup.appendChild(createSvgElement(document, "text", {
|
|
22
22
|
x: 0,
|
|
23
23
|
y: streamHeight / 2,
|
|
24
24
|
fill: s.title_color,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"font-family": s.title_font_family,
|
|
26
|
+
"font-size": s.title_font_size + "px",
|
|
27
|
+
"font-weight": s.title_font_weight,
|
|
28
|
+
"font-style": s.title_font_style,
|
|
29
|
+
"dominant-baseline": "middle",
|
|
30
30
|
}, title));
|
|
31
31
|
$outerGroup.appendChild($streamGroup);
|
|
32
32
|
translate($streamGroup, s.title_width, 0);
|
|
@@ -34,7 +34,7 @@ export const renderStream = (ctx, stream) => {
|
|
|
34
34
|
bbox.x2 += s.title_width;
|
|
35
35
|
return {
|
|
36
36
|
element: $outerGroup,
|
|
37
|
-
bbox
|
|
37
|
+
bbox,
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
//# sourceMappingURL=full.js.map
|
package/dist/stream/full.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full.js","sourceRoot":"","sources":["../../src/stream/full.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"full.js","sourceRoot":"","sources":["../../src/stream/full.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAoB,EAAE,MAA2B,EAAkB,EAAE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AkB;QACnC,YAAY,EAAE,CAAC,CAAC,gBAAiB;QACjC,mBAAmB,EAAE,QAAQ;KAC9B,EACD,KAAK,CACN,CACF,CAAC;IAEF,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,WAAY,EAAE,CAAC,CAAC,CAAC;IAE3C,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,WAAY,CAAC;IAE1B,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,IAAI;KACL,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { DecorationSpecification, DiagramStyles, MessageSpecification, SVGDocument } from
|
|
2
|
-
export
|
|
1
|
+
import { DecorationSpecification, DiagramStyles, MessageSpecification, SVGDocument } from "@swirly/types";
|
|
2
|
+
export type Point = {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type Rectangle = {
|
|
7
7
|
x1: number;
|
|
8
8
|
y1: number;
|
|
9
9
|
x2: number;
|
|
10
10
|
y2: number;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
12
|
+
export type TimeScaler = (time: number) => number;
|
|
13
|
+
export type RendererContext = {
|
|
14
14
|
DOMParser?: typeof DOMParser;
|
|
15
15
|
document: SVGDocument;
|
|
16
16
|
styles: DiagramStyles;
|
|
17
17
|
streamHeight: number;
|
|
18
18
|
streamTitleEnabled: boolean;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type RendererResult = {
|
|
21
21
|
element: SVGElement;
|
|
22
22
|
bbox: Rectangle;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type PostRenderUpdateContext = {
|
|
25
25
|
width: number;
|
|
26
26
|
height: number;
|
|
27
27
|
dx: number;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type UpdatableRendererResult = RendererResult & {
|
|
30
30
|
update?: (ctx: PostRenderUpdateContext) => void;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type MessageRendererOptions = {
|
|
33
33
|
verticalOffset: number;
|
|
34
34
|
valueAngle: number;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
37
|
-
export
|
|
36
|
+
export type MessageRenderer = (ctx: RendererContext, message: MessageSpecification, options: MessageRendererOptions) => RendererResult;
|
|
37
|
+
export type DecorationRendererContext = RendererContext & {
|
|
38
38
|
bbox: Rectangle;
|
|
39
39
|
scaleTime: TimeScaler;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type DecorationRendererResult = {
|
|
42
42
|
element: SVGElement;
|
|
43
43
|
bbox?: Rectangle;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
45
|
+
export type DecorationRenderer = (ctx: DecorationRendererContext, decoration: DecorationSpecification) => DecorationRendererResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"degrees-to-radians.js","sourceRoot":"","sources":["../../src/util/degrees-to-radians.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"degrees-to-radians.js","sourceRoot":"","sources":["../../src/util/degrees-to-radians.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC"}
|
package/dist/util/geometry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point, Rectangle } from
|
|
1
|
+
import { Point, Rectangle } from "../types.js";
|
|
2
2
|
export declare const translatePoint: (x: number, y: number, dx: number, dy: number) => Point;
|
|
3
3
|
export declare const translateRectangle: ({ x1, y1, x2, y2 }: Rectangle, dx: number, dy: number) => Rectangle;
|
|
4
4
|
export declare const rotatePoint: (x: number, y: number, angle: number, x0: number, y0: number) => Point;
|
package/dist/util/geometry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const translatePoint = (x, y, dx, dy) => ({
|
|
2
2
|
x: x + dx,
|
|
3
|
-
y: y + dy
|
|
3
|
+
y: y + dy,
|
|
4
4
|
});
|
|
5
5
|
export const translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
6
6
|
const p1 = translatePoint(x1, y1, dx, dy);
|
|
@@ -9,7 +9,7 @@ export const translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
|
9
9
|
x1: p1.x,
|
|
10
10
|
y1: p1.y,
|
|
11
11
|
x2: p2.x,
|
|
12
|
-
y2: p2.y
|
|
12
|
+
y2: p2.y,
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
export const rotatePoint = (x, y, angle, x0, y0) => {
|
|
@@ -19,7 +19,7 @@ export const rotatePoint = (x, y, angle, x0, y0) => {
|
|
|
19
19
|
y -= y0;
|
|
20
20
|
return {
|
|
21
21
|
x: x * c - y * s + x0,
|
|
22
|
-
y: x * s + y * c + y0
|
|
22
|
+
y: x * s + y * c + y0,
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
export const rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
@@ -29,19 +29,19 @@ export const rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
|
29
29
|
x1: p1.x,
|
|
30
30
|
y1: p1.y,
|
|
31
31
|
x2: p2.x,
|
|
32
|
-
y2: p2.y
|
|
32
|
+
y2: p2.y,
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
export const rectangleUnion = (rects) => {
|
|
36
36
|
const nonEmptyRects = rects.filter(({ x1, y1, x2, y2 }) => x2 - x1 !== 0 && y2 - y1 !== 0);
|
|
37
37
|
if (nonEmptyRects.length === 0) {
|
|
38
|
-
throw new Error(
|
|
38
|
+
throw new Error("All rectangles empty");
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
41
|
x1: Math.min(...nonEmptyRects.map((rect) => rect.x1)),
|
|
42
42
|
y1: Math.min(...nonEmptyRects.map((rect) => rect.y1)),
|
|
43
43
|
x2: Math.max(...nonEmptyRects.map((rect) => rect.x2)),
|
|
44
|
-
y2: Math.max(...nonEmptyRects.map((rect) => rect.y2))
|
|
44
|
+
y2: Math.max(...nonEmptyRects.map((rect) => rect.y2)),
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/util/geometry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/util/geometry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAU,EAAE,EAAU,EAAS,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,GAAG,EAAE;IACT,CAAC,EAAE,CAAC,GAAG,EAAE;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAa,EAC7B,EAAU,EACV,EAAU,EACC,EAAE;IACb,MAAM,EAAE,GAAG,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,CAAC;QACR,EAAE,EAAE,EAAE,CAAC,CAAC;QACR,EAAE,EAAE,EAAE,CAAC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EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3F,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrD,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrD,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrD,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACtD,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/util/hex-to-dec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex-to-dec.js","sourceRoot":"","sources":["../../src/util/hex-to-dec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"hex-to-dec.js","sourceRoot":"","sources":["../../src/util/hex-to-dec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC5B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE;IAC9C,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FreeformStyles } from
|
|
1
|
+
import { FreeformStyles } from "@swirly/types";
|
|
2
2
|
export declare const mergeStyles: (globalStyles: FreeformStyles, localStyles: FreeformStyles | null | undefined, globalPrefix: string, localStylesPrefixed?: boolean) => FreeformStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-styles.js","sourceRoot":"","sources":["../../src/util/merge-styles.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,YAA4B,EAC5B,WAA8C,EAC9C,YAAoB,EACpB,sBAA+B,KAAK,EACpB,EAAE;IAClB,MAAM,MAAM,GAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"merge-styles.js","sourceRoot":"","sources":["../../src/util/merge-styles.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,YAA4B,EAC5B,WAA8C,EAC9C,YAAoB,EACpB,sBAA+B,KAAK,EACpB,EAAE;IAClB,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3F,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7D,MAAM,CAAC,SAAS,CAAC;YACf,WAAW,IAAI,IAAI,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,IAAI;gBAClD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACvB,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export class NotificationKind {
|
|
2
|
-
static NEXT = new NotificationKind(
|
|
3
|
-
static COMPLETE = new NotificationKind(
|
|
4
|
-
static ERROR = new NotificationKind(
|
|
2
|
+
static NEXT = new NotificationKind("N");
|
|
3
|
+
static COMPLETE = new NotificationKind("C");
|
|
4
|
+
static ERROR = new NotificationKind("E");
|
|
5
5
|
#char;
|
|
6
6
|
constructor(char) {
|
|
7
7
|
this.#char = char;
|
|
8
8
|
}
|
|
9
9
|
equals(x) {
|
|
10
|
-
return typeof x ===
|
|
10
|
+
return typeof x === "string" && x.charAt(0).toUpperCase() === this.#char;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=notification-kind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,IAAI,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,IAAI,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,KAAK,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEzC,KAAK,CAAS;IAEd,YAAoB,IAAY;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,CAAM;QACX,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC;IAC3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const stringToColor: (str: string, mode:
|
|
1
|
+
export declare const stringToColor: (str: string, mode: "light" | "dark") => string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
|
-
import { sync as sha1 } from
|
|
3
|
-
import { hexToDec } from
|
|
2
|
+
import { sync as sha1 } from "simple-sha1";
|
|
3
|
+
import { hexToDec } from "./hex-to-dec.js";
|
|
4
4
|
export const stringToColor = (str, mode) => {
|
|
5
5
|
const hashHex = sha1(str);
|
|
6
6
|
const hash = hexToDec(hashHex.substring(4, 8));
|
|
7
7
|
const hue = Math.round((hash / (1 << 16)) * 360);
|
|
8
8
|
const saturation = 60;
|
|
9
|
-
const lightness = mode ===
|
|
9
|
+
const lightness = mode === "dark" ? 20 : 80;
|
|
10
10
|
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=string-to-color.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-to-color.js","sourceRoot":"","sources":["../../src/util/string-to-color.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"string-to-color.js","sourceRoot":"","sources":["../../src/util/string-to-color.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,IAAsB,EAAU,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,SAAS,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,OAAO,OAAO,GAAG,KAAK,UAAU,MAAM,SAAS,IAAI,CAAC;AACtD,CAAC,CAAC"}
|
package/dist/util/svg-xml.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SVGDocument } from
|
|
1
|
+
import { SVGDocument } from "@swirly/types";
|
|
2
2
|
export declare const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
3
|
export declare const SVG_MIME_TYPE = "image/svg+xml";
|
|
4
4
|
export declare const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
package/dist/util/svg-xml.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export const SVG_NS =
|
|
2
|
-
export const SVG_MIME_TYPE =
|
|
3
|
-
export const XHTML_NS =
|
|
1
|
+
export const SVG_NS = "http://www.w3.org/2000/svg";
|
|
2
|
+
export const SVG_MIME_TYPE = "image/svg+xml";
|
|
3
|
+
export const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
4
4
|
const EMPTY_SVG_XML = `<svg xmlns="${SVG_NS}"/>`;
|
|
5
5
|
const parseXml = (xml, mimeType, DOMParserImpl = DOMParser) => new DOMParserImpl().parseFromString(xml, mimeType);
|
|
6
6
|
export const createSvgDocument = (DOMParserImpl) => parseXml(EMPTY_SVG_XML, SVG_MIME_TYPE, DOMParserImpl);
|
|
7
|
-
export const createSvgElement = (document, name, attrs = {}, text =
|
|
7
|
+
export const createSvgElement = (document, name, attrs = {}, text = "") => {
|
|
8
8
|
const $el = document.createElementNS(SVG_NS, name);
|
|
9
9
|
for (const [name, value] of Object.entries(attrs)) {
|
|
10
10
|
$el.setAttribute(name, String(value));
|
|
11
11
|
}
|
|
12
|
-
if (text !==
|
|
12
|
+
if (text !== "") {
|
|
13
13
|
$el.textContent = text;
|
|
14
14
|
}
|
|
15
15
|
return $el;
|
|
16
16
|
};
|
|
17
17
|
export const setSvgDimensions = ($svg, width, height, scale = 1) => {
|
|
18
|
-
$svg.setAttribute(
|
|
19
|
-
$svg.setAttribute(
|
|
20
|
-
$svg.setAttribute(
|
|
18
|
+
$svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
19
|
+
$svg.setAttribute("width", String(width * scale));
|
|
20
|
+
$svg.setAttribute("height", String(height * scale));
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=svg-xml.js.map
|
package/dist/util/svg-xml.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg-xml.js","sourceRoot":"","sources":["../../src/util/svg-xml.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,G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,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC;IACvD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAClD,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC"}
|
package/dist/util/transform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const transform = ($element, value) => {
|
|
2
|
-
const existing = $element.getAttribute(
|
|
3
|
-
const updated = (existing != null && existing !==
|
|
4
|
-
$element.setAttribute(
|
|
2
|
+
const existing = $element.getAttribute("transform");
|
|
3
|
+
const updated = (existing != null && existing !== "" ? existing + " " : "") + value;
|
|
4
|
+
$element.setAttribute("transform", updated);
|
|
5
5
|
};
|
|
6
6
|
export const translate = ($element, x, y) => {
|
|
7
7
|
if (x === 0 && y === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/util/transform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/util/transform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;IACpF,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IACtE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IACD,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAAoB,EAAE,KAAa,EAAE,IAAY,CAAC,EAAE,IAAY,CAAC,EAAE,EAAE;IAC1F,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,SAAS,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swirly/renderer",
|
|
3
|
+
"version": "0.22.0",
|
|
3
4
|
"description": "Renderer for Swirly marble diagrams.",
|
|
4
|
-
"
|
|
5
|
+
"homepage": "https://swirly.tmdpw.eu",
|
|
5
6
|
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Tim De Pauw",
|
|
9
|
+
"url": "https://tmdpw.eu"
|
|
10
|
+
},
|
|
6
11
|
"repository": {
|
|
7
12
|
"type": "git",
|
|
8
13
|
"url": "https://github.com/timdp/swirly.git",
|
|
9
14
|
"directory": "packages/swirly-renderer"
|
|
10
15
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"url": "https://tmdpw.eu"
|
|
15
|
-
},
|
|
16
|
-
"type": "module",
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"access": "public"
|
|
16
|
+
"funding": {
|
|
17
|
+
"type": "github",
|
|
18
|
+
"url": "https://github.com/sponsors/timdp"
|
|
19
19
|
},
|
|
20
|
-
"main": "dist/index.js",
|
|
21
20
|
"files": [
|
|
22
21
|
"src/",
|
|
23
22
|
"dist/"
|
|
24
23
|
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
25
29
|
"scripts": {
|
|
26
30
|
"build": "yarn run clean && ../../scripts/build-ts.sh",
|
|
27
31
|
"clean": "shx rm -rf dist",
|
|
28
32
|
"prepare": "yarn run build"
|
|
29
33
|
},
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=14.13.1"
|
|
32
|
-
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@swirly/theme-default-light": "^0.
|
|
35
|
+
"@swirly/theme-default-light": "^0.22.0",
|
|
35
36
|
"simple-sha1": "^3.1.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@swirly/types": "^0.
|
|
39
|
-
"shx": "^0.
|
|
39
|
+
"@swirly/types": "^0.22.0",
|
|
40
|
+
"shx": "^0.4.0"
|
|
40
41
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"url": "https://github.com/sponsors/timdp"
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "74c54ea10427b5eac69b390a8d63fba76a195af2"
|
|
46
46
|
}
|
package/src/arrow.ts
CHANGED
|
@@ -1,66 +1,65 @@
|
|
|
1
|
-
import { RendererContext, RendererResult } from
|
|
2
|
-
import { degreesToRadians } from
|
|
3
|
-
import { createSvgElement } from
|
|
1
|
+
import { RendererContext, RendererResult } from "./types.js";
|
|
2
|
+
import { degreesToRadians } from "./util/degrees-to-radians.js";
|
|
3
|
+
import { createSvgElement } from "./util/svg-xml.js";
|
|
4
4
|
|
|
5
5
|
export const renderArrow = (
|
|
6
6
|
{ document, styles, streamHeight }: RendererContext,
|
|
7
7
|
arrowStyles: any,
|
|
8
8
|
arrowheadAngle: number,
|
|
9
|
-
duration: number
|
|
9
|
+
duration: number,
|
|
10
10
|
): RendererResult => {
|
|
11
|
-
const centerY = streamHeight / 2
|
|
12
|
-
const lineWidth = duration * styles.frame_width! + streamHeight
|
|
13
|
-
const arrowheadWidth = arrowStyles.width
|
|
14
|
-
const arrowheadHeight =
|
|
15
|
-
arrowheadWidth * Math.tan(degreesToRadians(arrowheadAngle / 2))
|
|
11
|
+
const centerY = streamHeight / 2;
|
|
12
|
+
const lineWidth = duration * styles.frame_width! + streamHeight;
|
|
13
|
+
const arrowheadWidth = arrowStyles.width!;
|
|
14
|
+
const arrowheadHeight = arrowheadWidth * Math.tan(degreesToRadians(arrowheadAngle / 2));
|
|
16
15
|
const arrowHeadProtrusion =
|
|
17
|
-
arrowStyles.stroke_width! / Math.sin(degreesToRadians(arrowheadAngle))
|
|
16
|
+
arrowStyles.stroke_width! / Math.sin(degreesToRadians(arrowheadAngle));
|
|
18
17
|
|
|
19
|
-
const strokeWidth = arrowStyles.stroke_width
|
|
20
|
-
const strokeColor = arrowStyles.stroke_color
|
|
21
|
-
const fillColor = arrowStyles.fill_color
|
|
22
|
-
const filled = typeof fillColor ===
|
|
18
|
+
const strokeWidth = arrowStyles.stroke_width!;
|
|
19
|
+
const strokeColor = arrowStyles.stroke_color!;
|
|
20
|
+
const fillColor = arrowStyles.fill_color!;
|
|
21
|
+
const filled = typeof fillColor === "string" && fillColor !== "";
|
|
23
22
|
|
|
24
|
-
const $group = createSvgElement(document,
|
|
23
|
+
const $group = createSvgElement(document, "g");
|
|
25
24
|
|
|
26
25
|
$group.appendChild(
|
|
27
|
-
createSvgElement(document,
|
|
26
|
+
createSvgElement(document, "line", {
|
|
28
27
|
x1: 0,
|
|
29
28
|
y1: centerY,
|
|
30
29
|
x2: lineWidth - (filled ? arrowheadWidth : 0),
|
|
31
30
|
y2: centerY,
|
|
32
31
|
stroke: strokeColor,
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
)
|
|
32
|
+
"stroke-width": strokeWidth,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
36
35
|
|
|
37
|
-
const arrowheadTopY = centerY - arrowheadHeight
|
|
38
|
-
const arrowheadBottomY = centerY + arrowheadHeight
|
|
36
|
+
const arrowheadTopY = centerY - arrowheadHeight;
|
|
37
|
+
const arrowheadBottomY = centerY + arrowheadHeight;
|
|
39
38
|
const points = [
|
|
40
39
|
`${lineWidth - arrowheadWidth},${arrowheadTopY}`,
|
|
41
40
|
`${lineWidth},${centerY}`,
|
|
42
|
-
`${lineWidth - arrowheadWidth},${arrowheadBottomY}
|
|
43
|
-
]
|
|
41
|
+
`${lineWidth - arrowheadWidth},${arrowheadBottomY}`,
|
|
42
|
+
];
|
|
44
43
|
|
|
45
44
|
$group.appendChild(
|
|
46
|
-
createSvgElement(document, filled ?
|
|
47
|
-
points: points.join(
|
|
48
|
-
fill: filled ? fillColor :
|
|
45
|
+
createSvgElement(document, filled ? "polygon" : "polyline", {
|
|
46
|
+
points: points.join(" "),
|
|
47
|
+
fill: filled ? fillColor : "none",
|
|
49
48
|
stroke: strokeColor,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
)
|
|
49
|
+
"stroke-width": strokeWidth,
|
|
50
|
+
"stroke-linecap": "square",
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
54
53
|
|
|
55
54
|
const bbox = {
|
|
56
55
|
x1: 0,
|
|
57
56
|
y1: 0,
|
|
58
57
|
x2: lineWidth + arrowHeadProtrusion,
|
|
59
|
-
y2: streamHeight
|
|
60
|
-
}
|
|
58
|
+
y2: streamHeight,
|
|
59
|
+
};
|
|
61
60
|
|
|
62
61
|
return {
|
|
63
62
|
element: $group,
|
|
64
|
-
bbox
|
|
65
|
-
}
|
|
66
|
-
}
|
|
63
|
+
bbox,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BarrierDecorationSpecification,
|
|
3
3
|
BarrierDecorationStyles,
|
|
4
|
-
DecorationSpecification
|
|
5
|
-
} from
|
|
4
|
+
DecorationSpecification,
|
|
5
|
+
} from "@swirly/types";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import { mergeStyles } from '../util/merge-styles.js'
|
|
12
|
-
import { createSvgElement } from '../util/svg-xml.js'
|
|
13
|
-
import { translate } from '../util/transform.js'
|
|
7
|
+
import { DecorationRendererContext, DecorationRendererResult } from "../types.js";
|
|
8
|
+
import { mergeStyles } from "../util/merge-styles.js";
|
|
9
|
+
import { createSvgElement } from "../util/svg-xml.js";
|
|
10
|
+
import { translate } from "../util/transform.js";
|
|
14
11
|
|
|
15
12
|
export const renderBarrierDecoration = (
|
|
16
13
|
{ document, styles, bbox, scaleTime }: DecorationRendererContext,
|
|
17
|
-
decoration: DecorationSpecification
|
|
14
|
+
decoration: DecorationSpecification,
|
|
18
15
|
): DecorationRendererResult => {
|
|
19
|
-
const { frame, styles: ownStyles } =
|
|
20
|
-
decoration as BarrierDecorationSpecification
|
|
16
|
+
const { frame, styles: ownStyles } = decoration as BarrierDecorationSpecification;
|
|
21
17
|
|
|
22
|
-
const s: BarrierDecorationStyles = mergeStyles(styles, ownStyles,
|
|
18
|
+
const s: BarrierDecorationStyles = mergeStyles(styles, ownStyles, "barrier_");
|
|
23
19
|
|
|
24
|
-
const x = scaleTime(frame) * styles.frame_width! - s.stroke_width! / 2
|
|
25
|
-
const y = bbox.y1
|
|
26
|
-
const height = bbox.y2 - bbox.y1
|
|
20
|
+
const x = scaleTime(frame) * styles.frame_width! - s.stroke_width! / 2;
|
|
21
|
+
const y = bbox.y1;
|
|
22
|
+
const height = bbox.y2 - bbox.y1;
|
|
27
23
|
|
|
28
|
-
const $line = createSvgElement(document,
|
|
24
|
+
const $line = createSvgElement(document, "line", {
|
|
29
25
|
x1: 0,
|
|
30
26
|
y1: 0,
|
|
31
27
|
x2: 0,
|
|
32
28
|
y2: height,
|
|
33
29
|
stroke: s.color!,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
30
|
+
"stroke-width": s.stroke_width!,
|
|
31
|
+
"stroke-dasharray": s.stroke_dash_width!,
|
|
32
|
+
});
|
|
37
33
|
|
|
38
|
-
translate($line, x, y)
|
|
34
|
+
translate($line, x, y);
|
|
39
35
|
|
|
40
36
|
return {
|
|
41
|
-
element: $line
|
|
42
|
-
}
|
|
43
|
-
}
|
|
37
|
+
element: $line,
|
|
38
|
+
};
|
|
39
|
+
};
|