@univerjs-pro/engine-chart 0.25.1 → 1.0.0-alpha.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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/enum.d.ts +3 -0
- package/lib/types/index.d.ts +23 -20
- package/lib/types/{model → models}/chart-data-operators/operators.d.ts +6 -10
- package/lib/types/{model → models}/chart-model.d.ts +152 -115
- package/lib/types/models/chart-runtime-axes.d.ts +38 -0
- package/lib/types/models/chart-runtime-style.d.ts +12 -0
- package/lib/types/{model → models}/constants/default-chart-style.d.ts +4 -2
- package/lib/types/{model → models}/echart-render-model.d.ts +6 -1
- package/lib/types/models/mode-converter/converters/word-cloud-converter.d.ts +2 -0
- package/lib/types/{model → models}/mode-converter/mode-converter.d.ts +2 -2
- package/lib/types/models/mode-converter/render-spec-operators/implicit-category-axis.operator.d.ts +2 -0
- package/lib/types/{model → models}/mode-converter/render-spec-operators/index.d.ts +2 -0
- package/lib/types/models/mode-converter/render-spec-operators/legend-size.d.ts +2 -0
- package/lib/types/models/mode-converter/render-spec-operators/rtl-render-spec.operator.d.ts +2 -0
- package/lib/types/models/mode-converter/render-spec-operators/tool-tip-operator.d.ts +37 -0
- package/lib/types/models/mode-converter/render-spec-operators/tool-tip-renderer.d.ts +15 -0
- package/lib/types/{model → models}/word-cloud-musk-image.service.d.ts +1 -1
- package/lib/types/source/option-data-value.d.ts +3 -0
- package/lib/types/source/source-util.d.ts +2 -2
- package/lib/types/source/static-chart-source.d.ts +1 -0
- package/lib/types/types.d.ts +21 -8
- package/lib/types/util.d.ts +2 -1
- package/lib/types/utils/echarts.d.ts +3 -2
- package/lib/types/word-cloud-resource/word-cloud-shape-resource.d.ts +5 -0
- package/lib/types/wordcloud-chart/adapters/echarts/chart-view.d.ts +7 -0
- package/lib/types/wordcloud-chart/adapters/echarts/echarts-options.d.ts +24 -0
- package/lib/types/wordcloud-chart/adapters/echarts/install.d.ts +4 -0
- package/lib/types/wordcloud-chart/adapters/echarts/layout-register.d.ts +5 -0
- package/lib/types/wordcloud-chart/adapters/echarts/layout.d.ts +82 -0
- package/lib/types/wordcloud-chart/adapters/echarts/render-config.d.ts +57 -0
- package/lib/types/wordcloud-chart/adapters/echarts/series-model.d.ts +7 -0
- package/lib/types/wordcloud-chart/adapters/echarts/text-measurer.d.ts +12 -0
- package/lib/types/wordcloud-chart/adapters/echarts/words.d.ts +47 -0
- package/lib/types/wordcloud-chart/canvas.d.ts +8 -0
- package/lib/types/wordcloud-chart/core/collision/bitset-board.d.ts +45 -0
- package/lib/types/wordcloud-chart/core/collision/box-shape-engine.d.ts +31 -0
- package/lib/types/wordcloud-chart/core/collision/engine.d.ts +67 -0
- package/lib/types/wordcloud-chart/core/collision/failure-cache.d.ts +6 -0
- package/lib/types/wordcloud-chart/core/collision/footprint.d.ts +13 -0
- package/lib/types/wordcloud-chart/core/collision/glyph-shape-engine.d.ts +49 -0
- package/lib/types/wordcloud-chart/core/collision/grid.d.ts +10 -0
- package/lib/types/wordcloud-chart/core/collision/types.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/layout/candidates.d.ts +15 -0
- package/lib/types/wordcloud-chart/core/layout/font-scale.d.ts +66 -0
- package/lib/types/wordcloud-chart/core/layout/layout-config.d.ts +3 -0
- package/lib/types/wordcloud-chart/core/layout/layout.d.ts +4 -0
- package/lib/types/wordcloud-chart/core/layout/phases.d.ts +12 -0
- package/lib/types/wordcloud-chart/core/layout/place-word.d.ts +12 -0
- package/lib/types/wordcloud-chart/core/layout/placement-stats.d.ts +7 -0
- package/lib/types/wordcloud-chart/core/layout/placement-types.d.ts +28 -0
- package/lib/types/wordcloud-chart/core/layout/placement-word-manager.d.ts +23 -0
- package/lib/types/wordcloud-chart/core/layout/rotation.d.ts +10 -0
- package/lib/types/wordcloud-chart/core/layout/runtime-mask.d.ts +6 -0
- package/lib/types/wordcloud-chart/core/layout/search-plan.d.ts +51 -0
- package/lib/types/wordcloud-chart/core/layout/types.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/layout/word-prepare.d.ts +3 -0
- package/lib/types/wordcloud-chart/core/layout/word-shrink.d.ts +39 -0
- package/lib/types/wordcloud-chart/core/random/seed.d.ts +3 -0
- package/lib/types/wordcloud-chart/core/shape/built-in-shapes.d.ts +14 -0
- package/lib/types/wordcloud-chart/core/shape/shape-mask.d.ts +12 -0
- package/lib/types/wordcloud-chart/core/shape/shape-profile.d.ts +20 -0
- package/lib/types/wordcloud-chart/core/shape/sprite-shape.d.ts +19 -0
- package/lib/types/wordcloud-chart/core/shape/types.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/text/formatter.d.ts +2 -0
- package/lib/types/wordcloud-chart/core/text/measure.d.ts +8 -0
- package/lib/types/wordcloud-chart/core/text/normalize.d.ts +2 -0
- package/lib/types/wordcloud-chart/core/text/sprite.d.ts +17 -0
- package/lib/types/wordcloud-chart/core/text/types.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/types/layout.d.ts +81 -0
- package/lib/types/wordcloud-chart/core/types/option.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/types/shape.d.ts +1 -0
- package/lib/types/wordcloud-chart/core/types/word.d.ts +1 -0
- package/lib/types/wordcloud-chart/defaults.d.ts +70 -0
- package/lib/types/wordcloud-chart/echarts.d.ts +2 -0
- package/lib/types/wordcloud-chart/index.d.ts +11 -0
- package/lib/types/wordcloud-chart/types.d.ts +339 -0
- package/lib/types/wordcloud-chart/word-cloud-render-config.d.ts +30 -0
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- package/lib/types/model/mode-converter/converters/word-cloud-converter.d.ts +0 -76
- package/lib/types/model/mode-converter/render-spec-operators/tool-tip-operator.d.ts +0 -3
- /package/lib/types/{model → models}/chart-data-operators/build-chart-data.d.ts +0 -0
- /package/lib/types/{model → models}/chart-data-operators/index.d.ts +0 -0
- /package/lib/types/{model → models}/chart-locale-texts.d.ts +0 -0
- /package/lib/types/{model → models}/chart-theme.service.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/default.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/index.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/theme-util.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/types.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient1.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient2.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient3.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient4.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient5.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer-gradient6.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer1.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer2.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer3.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer4.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer5.d.ts +0 -0
- /package/lib/types/{model → models}/constants/build-in-theme/univer6.d.ts +0 -0
- /package/lib/types/{model → models}/constants/default.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/bar-data-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/box-plot-data-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/line-like-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/pareto-data-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/percent-data-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/pie-data-context-transformer.d.ts +0 -0
- /package/lib/types/{model → models}/data-context-transformers/word-cloud-data-context-transform.d.ts +0 -0
- /package/lib/types/{model → models}/echart-to-chart-model-init.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/boxplot-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/bubble-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/combination-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/constants.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/funnel-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/heatmap-chart-convert.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/pareto-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/pie-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/radar-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/relation-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/sankey-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/scatter-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/tools.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/converters/waterfall-chart-converter.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/axis-title.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/bubble-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/chart-axes.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/chart-box-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/empty-style-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/font-size.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/grid-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/heatmap-chart-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/hover-mark-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/invalid-value-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/legend-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/line-like-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/operator-types.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/pie-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/radar-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/relation-chart-operator/relation-chart-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/relation-chart-operator/relation-force-directed-layout.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/sankey-chart-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/scatter-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/series-style-operator/pareto-series-style.handler.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/series-style-operator/series-chart-style.handler.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/series-style-operator/series-data-label.handler.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/series-style-operator/series-style-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/series-style-operator/waterfall-series-style-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/stack.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/theme.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/title-style.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/tools.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/trend-line/trend-line.operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/trend-line/trendline-util.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/visual-map-operator.d.ts +0 -0
- /package/lib/types/{model → models}/mode-converter/render-spec-operators/watermark.operator.d.ts +0 -0
- /package/lib/types/{model → models}/spec-converter/spec-converter.d.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface IPixelBitsetBoard {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly height: number;
|
|
4
|
+
readonly stride: number;
|
|
5
|
+
readonly words: Uint32Array;
|
|
6
|
+
blockedPixelCount: number;
|
|
7
|
+
occupiedPixelCount: number;
|
|
8
|
+
}
|
|
9
|
+
export interface IPixelBitsetSprite {
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
readonly stride: number;
|
|
13
|
+
readonly words: Uint32Array;
|
|
14
|
+
readonly activeWords: readonly IPixelBitsetSpriteWord[];
|
|
15
|
+
readonly activeWordCount: number;
|
|
16
|
+
readonly alphaPixelCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface IPixelBitsetSpriteWord {
|
|
19
|
+
readonly row: number;
|
|
20
|
+
readonly wordIndex: number;
|
|
21
|
+
readonly bits: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ICreateBitsetBoardOptions {
|
|
24
|
+
readonly shapeMask?: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
export interface ICreateBitsetSpriteOptions {
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly height: number;
|
|
29
|
+
readonly pixels: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
export interface ICreateBitsetSpriteFromSpansOptions {
|
|
32
|
+
readonly width: number;
|
|
33
|
+
readonly height: number;
|
|
34
|
+
readonly spans: readonly IPixelBitsetSpriteSpan[];
|
|
35
|
+
}
|
|
36
|
+
export interface IPixelBitsetSpriteSpan {
|
|
37
|
+
readonly y: number;
|
|
38
|
+
readonly x0: number;
|
|
39
|
+
readonly x1: number;
|
|
40
|
+
}
|
|
41
|
+
export declare function createBitsetBoard(width: number, height: number, options?: ICreateBitsetBoardOptions): IPixelBitsetBoard;
|
|
42
|
+
export declare function createBitsetSpriteFromPixels(options: ICreateBitsetSpriteOptions): IPixelBitsetSprite;
|
|
43
|
+
export declare function createBitsetSpriteFromSpans(options: ICreateBitsetSpriteFromSpansOptions): IPixelBitsetSprite;
|
|
44
|
+
export declare function collideSprite(board: IPixelBitsetBoard, sprite: IPixelBitsetSprite, left: number, top: number): boolean;
|
|
45
|
+
export declare function stampSprite(board: IPixelBitsetBoard, sprite: IPixelBitsetSprite, left: number, top: number): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord } from '../../types';
|
|
2
|
+
import type { IBoxFootprint, IWordCloudLayoutGrid } from '../layout/types';
|
|
3
|
+
import type { ICollisionCandidate, ICollisionEngine, ICollisionEngineStats, ICollisionTextStyle } from './engine';
|
|
4
|
+
export declare class BoxShapeEngine implements ICollisionEngine<IBoxFootprint> {
|
|
5
|
+
private readonly _grid;
|
|
6
|
+
private readonly _shapeGrid;
|
|
7
|
+
readonly collisionShape: "box";
|
|
8
|
+
private readonly _footprintCache;
|
|
9
|
+
private readonly _placed;
|
|
10
|
+
private readonly _spatialIndex;
|
|
11
|
+
private readonly _blockedCenters;
|
|
12
|
+
private readonly _spatialCellSize;
|
|
13
|
+
private readonly _shapeIsFull;
|
|
14
|
+
private _nextSpatialQueryId;
|
|
15
|
+
private readonly _stats;
|
|
16
|
+
private _lastShapeCheck;
|
|
17
|
+
constructor(_grid: IWordCloudLayoutGrid, _shapeGrid: Uint8Array);
|
|
18
|
+
createFootprint(_word: IWordCloudEncodedWord, style: ICollisionTextStyle, rotation: number): IBoxFootprint;
|
|
19
|
+
getBounds(footprint: IBoxFootprint, candidate: ICollisionCandidate): import("../..").IWordCloudBounds;
|
|
20
|
+
isInsideLayout(footprint: IBoxFootprint, candidate: ICollisionCandidate, width: number, height: number): boolean;
|
|
21
|
+
canPlace(footprint: IBoxFootprint, candidate: ICollisionCandidate): boolean;
|
|
22
|
+
isShapeBlocked(footprint: IBoxFootprint, candidate: ICollisionCandidate): boolean;
|
|
23
|
+
commit(footprint: IBoxFootprint, candidate: ICollisionCandidate): void;
|
|
24
|
+
getStats(): ICollisionEngineStats;
|
|
25
|
+
private isBoxInsideShape;
|
|
26
|
+
private rememberShapeCheck;
|
|
27
|
+
private getRememberedShapeCheck;
|
|
28
|
+
private visitNearby;
|
|
29
|
+
private insertSpatial;
|
|
30
|
+
private isCandidateCenterBlocked;
|
|
31
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { IWordCloudBounds, IWordCloudClipMask, IWordCloudEncodedWord, IWordCloudTextMeasurer, IWordCloudTextSprite } from '../../types';
|
|
2
|
+
import type { IWordCloudLayoutGrid } from '../layout/types';
|
|
3
|
+
export type WordCloudCollisionShape = 'box' | 'glyph';
|
|
4
|
+
export type WordCloudRejectReason = 'collision' | 'shape';
|
|
5
|
+
export interface ICollisionEngineStats {
|
|
6
|
+
readonly spatialQueryCount: number;
|
|
7
|
+
readonly avgNearbyBoxCount: number;
|
|
8
|
+
readonly aabbRejectCount: number;
|
|
9
|
+
readonly satTestCount: number;
|
|
10
|
+
readonly satCollisionCount: number;
|
|
11
|
+
readonly shapeSampleCheckCount?: number;
|
|
12
|
+
readonly centerInsideRejectCount?: number;
|
|
13
|
+
readonly centerBlockCacheHitCount?: number;
|
|
14
|
+
readonly pixelCanPlaceCallCount?: number;
|
|
15
|
+
readonly pixelCanPlaceRejectCount?: number;
|
|
16
|
+
readonly pixelIsShapeBlockedCallCount?: number;
|
|
17
|
+
readonly pixelSpriteCacheHit?: number;
|
|
18
|
+
readonly pixelSpriteCacheMiss?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ICollisionTextStyle {
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly height: number;
|
|
23
|
+
readonly padding: number;
|
|
24
|
+
readonly dpr?: number;
|
|
25
|
+
readonly sprite?: IWordCloudTextSprite;
|
|
26
|
+
}
|
|
27
|
+
export interface ICollisionCandidate {
|
|
28
|
+
readonly index: number;
|
|
29
|
+
readonly row: number;
|
|
30
|
+
readonly col: number;
|
|
31
|
+
readonly x: number;
|
|
32
|
+
readonly y: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ICollisionFootprint {
|
|
35
|
+
readonly key: string;
|
|
36
|
+
readonly staticKey?: string;
|
|
37
|
+
readonly width: number;
|
|
38
|
+
readonly height: number;
|
|
39
|
+
readonly rawWidth: number;
|
|
40
|
+
readonly rawHeight: number;
|
|
41
|
+
readonly angle: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ICollisionShapeEngine<TFootprint extends ICollisionFootprint = ICollisionFootprint> {
|
|
44
|
+
readonly collisionShape: WordCloudCollisionShape;
|
|
45
|
+
readonly cacheCollisionFailures?: boolean;
|
|
46
|
+
createFootprint(word: IWordCloudEncodedWord, style: ICollisionTextStyle, rotation: number): TFootprint;
|
|
47
|
+
getBounds(footprint: TFootprint, candidate: ICollisionCandidate): IWordCloudBounds;
|
|
48
|
+
canPossiblyPlace?(footprint: TFootprint): boolean;
|
|
49
|
+
getPossibleRejectReason?(footprint: TFootprint): WordCloudRejectReason;
|
|
50
|
+
isInsideLayout?(footprint: TFootprint, candidate: ICollisionCandidate, width: number, height: number): boolean;
|
|
51
|
+
canPlace(footprint: TFootprint, candidate: ICollisionCandidate): boolean;
|
|
52
|
+
canPlaceBounds?(footprint: TFootprint, bounds: IWordCloudBounds): boolean;
|
|
53
|
+
isShapeBlocked?(footprint: TFootprint, candidate: ICollisionCandidate): boolean;
|
|
54
|
+
getClipBounds?(footprint: TFootprint, candidate: ICollisionCandidate): IWordCloudBounds | undefined;
|
|
55
|
+
getClipMask?(footprint: TFootprint, candidate: ICollisionCandidate): IWordCloudClipMask | undefined;
|
|
56
|
+
getStats?(): ICollisionEngineStats;
|
|
57
|
+
commit(footprint: TFootprint, candidate: ICollisionCandidate): void;
|
|
58
|
+
}
|
|
59
|
+
export type ICollisionEngine<TFootprint extends ICollisionFootprint = ICollisionFootprint> = ICollisionShapeEngine<TFootprint>;
|
|
60
|
+
export interface ICollisionEngineContext {
|
|
61
|
+
readonly grid: IWordCloudLayoutGrid;
|
|
62
|
+
readonly shapeGrid: Uint8Array;
|
|
63
|
+
readonly measurer: IWordCloudTextMeasurer;
|
|
64
|
+
readonly drawOutOfBound?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare function normalizeCollisionShape(shape: unknown): WordCloudCollisionShape;
|
|
67
|
+
export declare function createCollisionShapeEngine(shape: WordCloudCollisionShape, context: ICollisionEngineContext): ICollisionShapeEngine;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IWordCloudBounds, IWordCloudMeasureResult } from '../../types';
|
|
2
|
+
import type { IBoxFootprint, IWordCloudLayoutGrid } from './types';
|
|
3
|
+
export interface IBoxTightTextBox {
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
readonly angle: number;
|
|
7
|
+
readonly corners: ReadonlyArray<readonly [number, number]>;
|
|
8
|
+
readonly bounds: IWordCloudBounds;
|
|
9
|
+
}
|
|
10
|
+
export declare function createBoxFromTightTextBox(textMetrics: IWordCloudMeasureResult, angle: number, padding: number): IBoxTightTextBox;
|
|
11
|
+
export declare function createBoxFootprint(grid: IWordCloudLayoutGrid, rawWidth: number, rawHeight: number, angle: number): IBoxFootprint;
|
|
12
|
+
export declare function getCachedBoxFootprint(cache: Map<string, IBoxFootprint>, grid: IWordCloudLayoutGrid, rawWidth: number, rawHeight: number, angle: number): IBoxFootprint;
|
|
13
|
+
export declare function getBoxBounds(x: number, y: number, footprint: IBoxFootprint): IWordCloudBounds;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { IWordCloudBounds, IWordCloudClipMask, IWordCloudEncodedWord, IWordCloudTextMeasurer } from '../../types';
|
|
2
|
+
import type { IWordCloudLayoutGrid } from '../layout/types';
|
|
3
|
+
import type { IPixelBitsetSprite } from './bitset-board';
|
|
4
|
+
import type { ICollisionCandidate, ICollisionEngine, ICollisionFootprint, ICollisionTextStyle } from './engine';
|
|
5
|
+
interface IPixelSpan {
|
|
6
|
+
readonly y: number;
|
|
7
|
+
readonly x0: number;
|
|
8
|
+
readonly x1: number;
|
|
9
|
+
}
|
|
10
|
+
export interface IPixelFootprint extends ICollisionFootprint {
|
|
11
|
+
readonly anchorX: number;
|
|
12
|
+
readonly anchorY: number;
|
|
13
|
+
readonly pixels: Uint8Array;
|
|
14
|
+
readonly sprite: IPixelBitsetSprite;
|
|
15
|
+
readonly rowSpans: readonly IPixelSpan[];
|
|
16
|
+
}
|
|
17
|
+
export declare class GlyphShapeEngine implements ICollisionEngine<IPixelFootprint> {
|
|
18
|
+
private readonly _grid;
|
|
19
|
+
private readonly _shapeGrid;
|
|
20
|
+
private readonly _measurer;
|
|
21
|
+
private readonly _cacheLimit;
|
|
22
|
+
private readonly _clipToShape;
|
|
23
|
+
readonly collisionShape: "glyph";
|
|
24
|
+
readonly cacheCollisionFailures = false;
|
|
25
|
+
private readonly _spriteCache;
|
|
26
|
+
private readonly _board;
|
|
27
|
+
private readonly _shapeBoard;
|
|
28
|
+
private _lastClip;
|
|
29
|
+
constructor(_grid: IWordCloudLayoutGrid, _shapeGrid: Uint8Array, _measurer: IWordCloudTextMeasurer, _cacheLimit?: number, _clipToShape?: boolean);
|
|
30
|
+
createFootprint(word: IWordCloudEncodedWord, style: ICollisionTextStyle, rotation: number): IPixelFootprint;
|
|
31
|
+
getBounds(footprint: IPixelFootprint, candidate: ICollisionCandidate): {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
canPossiblyPlace(footprint: IPixelFootprint): boolean;
|
|
38
|
+
getPossibleRejectReason(footprint: IPixelFootprint): 'shape' | 'collision';
|
|
39
|
+
isInsideLayout(footprint: IPixelFootprint, candidate: ICollisionCandidate, width: number, height: number): boolean;
|
|
40
|
+
canPlace(footprint: IPixelFootprint, candidate: ICollisionCandidate): boolean;
|
|
41
|
+
canPlaceBounds(footprint: IPixelFootprint, bounds: IWordCloudBounds): boolean;
|
|
42
|
+
isShapeBlocked(footprint: IPixelFootprint, candidate: ICollisionCandidate): boolean;
|
|
43
|
+
getClipBounds(footprint: IPixelFootprint, candidate: ICollisionCandidate): IWordCloudBounds | undefined;
|
|
44
|
+
getClipMask(footprint: IPixelFootprint, candidate: ICollisionCandidate): IWordCloudClipMask | undefined;
|
|
45
|
+
private canPlaceAt;
|
|
46
|
+
commit(footprint: IPixelFootprint, candidate: ICollisionCandidate): void;
|
|
47
|
+
private getClippedPlacement;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IBoxFootprint, IWordCloudLayoutGrid } from './types';
|
|
2
|
+
export declare function createWordCloudGrid(width: number, height: number, cellSize: number): IWordCloudLayoutGrid;
|
|
3
|
+
export declare function getCellCenter(grid: IWordCloudLayoutGrid, index: number): {
|
|
4
|
+
row: number;
|
|
5
|
+
col: number;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function getCellIndex(grid: IWordCloudLayoutGrid, row: number, col: number): number;
|
|
10
|
+
export declare function commitBoxFootprint(grid: IWordCloudLayoutGrid, footprint: IBoxFootprint, centerIndex: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from '../types/layout';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ICollisionCandidate } from '../collision/engine';
|
|
2
|
+
import type { IWordCloudShapeProfile } from '../shape/shape-profile';
|
|
3
|
+
import type { IWordCloudPlacementContext } from './placement-types';
|
|
4
|
+
import type { IPreparedWordCloudWord, IWordCloudLayoutConfig, IWordCloudLayoutGrid, IWordCloudLayoutRuntime } from './types';
|
|
5
|
+
export interface IEnumerateCandidatePointsOptions {
|
|
6
|
+
readonly grid: IWordCloudLayoutGrid;
|
|
7
|
+
readonly shapeGrid: Uint8Array;
|
|
8
|
+
readonly maxPoints: number;
|
|
9
|
+
readonly stepCells?: number;
|
|
10
|
+
readonly shapeProfile?: IWordCloudShapeProfile;
|
|
11
|
+
}
|
|
12
|
+
export declare function enumerateCandidatePoints(options: IEnumerateCandidatePointsOptions): ICollisionCandidate[];
|
|
13
|
+
export declare function createFineCandidatePoints(context: IWordCloudPlacementContext, primaryCandidatePoints: readonly ICollisionCandidate[]): ICollisionCandidate[];
|
|
14
|
+
export declare function shouldUseFinePixelCandidates(word: IPreparedWordCloudWord, config: IWordCloudLayoutConfig, runtime: IWordCloudLayoutRuntime): boolean;
|
|
15
|
+
export declare function getFineCandidateMultiplier(context: IWordCloudPlacementContext): number;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wordcloud-font-size-scale.ts
|
|
3
|
+
*
|
|
4
|
+
* A single-file implementation of the reference wordCloud font-size pipeline.
|
|
5
|
+
*
|
|
6
|
+
* Scope:
|
|
7
|
+
* - This file copies the *font size mapping* behavior used by the ordinary wordCloud transform:
|
|
8
|
+
* value field -> signed sqrt scale -> fontSizeRange.
|
|
9
|
+
* What this intentionally does NOT do:
|
|
10
|
+
* - It does not copy the full pixel/grid collision layout. If you need 1:1 placement, use @visactor/vlayouts
|
|
11
|
+
* directly. This file is for engines that already have their own tryPlaceWord/layout implementation.
|
|
12
|
+
*
|
|
13
|
+
* Notes from upstream behavior:
|
|
14
|
+
* - The chart layer passes fontSize as { field: valueField } and fontSizeRange as the configured range.
|
|
15
|
+
* - When fontSizeRange === 'auto', it passes null to the layout transform.
|
|
16
|
+
* - The ordinary VGrammar wordcloud transform only applies fontSizeRange when fontSize is not a fixed number.
|
|
17
|
+
* - The scale is sqrt-based, with signed sqrt support for negative numbers.
|
|
18
|
+
* - If the data has exactly one item, extent shifts min downward so the single word maps to the max font size.
|
|
19
|
+
*
|
|
20
|
+
* License note:
|
|
21
|
+
* - This is an MIT-compatible source-level port of small algorithmic utilities from VisActor/VGrammar.
|
|
22
|
+
* Keep this header if copied into your project.
|
|
23
|
+
*/
|
|
24
|
+
export interface IFieldOption {
|
|
25
|
+
field: string;
|
|
26
|
+
}
|
|
27
|
+
export type CallbackOption<T, R = any> = (datum: T, index: number, data: T[]) => R;
|
|
28
|
+
export interface IWordCloudFontSizeMeta {
|
|
29
|
+
/** Effective range after applying the `fontSizeRange === 'auto' ? null : range` rule. */
|
|
30
|
+
effectiveFontSizeRange: [number, number] | null;
|
|
31
|
+
/** Data extent used before sqrt scale. */
|
|
32
|
+
extent: [number, number] | null;
|
|
33
|
+
/** True when field/callback fontSize is mapped through sqrt scale. */
|
|
34
|
+
usedSqrtRangeScale: boolean;
|
|
35
|
+
/** True when fontSize is a fixed number and range is ignored. */
|
|
36
|
+
fixedFontSize: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const WORD_CLOUD_DEFAULT_FONT_SIZE_RANGE: [number, number];
|
|
39
|
+
/**
|
|
40
|
+
* Direct port of VGrammar's fontSize + fontSizeRange decision:
|
|
41
|
+
* - `fontSize = field(options.fontSize) || 14`
|
|
42
|
+
* - `fontSizeRange` applies only when fontSize is not a fixed number
|
|
43
|
+
* - mapping is sqrt scale over extent(data)
|
|
44
|
+
*/
|
|
45
|
+
export declare function createWordCloudFontSizeAccessor<T extends Record<string, any>>(data: T[], options: {
|
|
46
|
+
fontSize?: IFieldOption | CallbackOption<T, number> | number;
|
|
47
|
+
fontSizeRange?: [number, number] | null;
|
|
48
|
+
}): {
|
|
49
|
+
fontSize: CallbackOption<T, number>;
|
|
50
|
+
sourceValue: CallbackOption<T, number>;
|
|
51
|
+
meta: IWordCloudFontSizeMeta;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Chart rule: spec.fontSizeRange === 'auto' is passed to the transform as null.
|
|
55
|
+
* For ordinary wordcloud, null means "do not run fontSizeRange sqrt mapping here".
|
|
56
|
+
*/
|
|
57
|
+
export declare function normalizeWordCloudFontSizeRange(fontSizeRange: [number, number] | 'auto' | null | undefined): [number, number] | null;
|
|
58
|
+
/** Signed sqrt used by VGrammar wordcloud scale. */
|
|
59
|
+
export declare function signedSqrt(x: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Direct port of VGrammar `generateScale(extent, range)` for font size.
|
|
62
|
+
* Note: VGrammar's `type` argument exists but sqrt behavior is used by default.
|
|
63
|
+
*/
|
|
64
|
+
export declare function generateWordCloudSqrtScale(domain: [number, number], range: [number, number]): (datum: number) => number;
|
|
65
|
+
/** Direct port of VGrammar extent behavior, including the single-data max-size trick. */
|
|
66
|
+
export declare function extent<T extends Record<string, any>>(fieldAccessor: CallbackOption<T, number>, data: T[]): [number, number];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord, IWordCloudLayoutOptions, IWordCloudLayoutResult } from '../../types';
|
|
2
|
+
import type { IWordCloudLayoutRuntime } from './types';
|
|
3
|
+
export declare function layoutWordCloudGridWords(words: readonly IWordCloudEncodedWord[], options: IWordCloudLayoutOptions, runtime: IWordCloudLayoutRuntime): IWordCloudLayoutResult;
|
|
4
|
+
export declare const layoutWordCloud: typeof layoutWordCloudGridWords;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord, IWordCloudPlacedWord } from '../../types';
|
|
2
|
+
import type { IPreparedWordCloudWord, IWordCloudLayoutConfig, IWordCloudLayoutGrid, IWordCloudLayoutRuntime } from './types';
|
|
3
|
+
import type { IWordCloudShapeProfile } from '../shape/shape-profile';
|
|
4
|
+
import { layoutWords } from './place-word';
|
|
5
|
+
export interface IWordCloudLayoutPhasesResult {
|
|
6
|
+
readonly prepared: IPreparedWordCloudWord[];
|
|
7
|
+
readonly placedByKey: Map<string, IWordCloudPlacedWord>;
|
|
8
|
+
readonly fillingWords: IWordCloudPlacedWord[];
|
|
9
|
+
readonly stats: NonNullable<ReturnType<typeof layoutWords>['stats']>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createInvisibleWordCloudWord(word: IWordCloudEncodedWord): IWordCloudPlacedWord;
|
|
12
|
+
export declare function layoutWordCloudPhases(words: readonly IWordCloudEncodedWord[], config: IWordCloudLayoutConfig, runtime: IWordCloudLayoutRuntime, grid: IWordCloudLayoutGrid, shapeGrid: Uint8Array, shapeProfile?: IWordCloudShapeProfile): IWordCloudLayoutPhasesResult;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IWordCloudLayoutStats, IWordCloudPlacedWord } from '../../types';
|
|
2
|
+
import type { IWordCloudPlacementContext, IWordCloudTryPlaceResult } from './placement-types';
|
|
3
|
+
import type { PlacementSearchPlan } from './search-plan';
|
|
4
|
+
import type { IPreparedWordCloudWord, IWordCloudPlacement } from './types';
|
|
5
|
+
export declare function tryPlaceWord(context: IWordCloudPlacementContext, word: IPreparedWordCloudWord, phase: 1 | 2, rank: number, searchPlan?: Extract<PlacementSearchPlan, {
|
|
6
|
+
action: 'process';
|
|
7
|
+
}>): IWordCloudTryPlaceResult;
|
|
8
|
+
export declare function placeWord(context: IWordCloudPlacementContext, word: IPreparedWordCloudWord, phase: 1 | 2, rank: number): IWordCloudPlacement | undefined;
|
|
9
|
+
export declare function layoutWords(words: readonly IPreparedWordCloudWord[], context: IWordCloudPlacementContext): {
|
|
10
|
+
placedByKey: Map<string, IWordCloudPlacedWord>;
|
|
11
|
+
stats: IWordCloudLayoutStats;
|
|
12
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IWordCloudLayoutStats, IWordCloudPlacedWord } from '../../types';
|
|
2
|
+
import type { IWordCloudTryPlaceResult } from './placement-types';
|
|
3
|
+
import type { IPreparedWordCloudWord, IWordCloudLayoutConfig } from './types';
|
|
4
|
+
export declare function createPlacementStats(): IWordCloudLayoutStats;
|
|
5
|
+
export declare function recordPlacementResult(stats: IWordCloudLayoutStats | undefined, result: IWordCloudTryPlaceResult): void;
|
|
6
|
+
export declare function recordSkippedPlacementResult(stats: IWordCloudLayoutStats | undefined, count?: number): void;
|
|
7
|
+
export declare function finalizePlacementStats(stats: IWordCloudLayoutStats, words: readonly IPreparedWordCloudWord[], placed: Iterable<IWordCloudPlacedWord>, config: IWordCloudLayoutConfig, durationMs: number): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IWordCloudLayoutStats } from '../../types';
|
|
2
|
+
import type { ICollisionCandidate, ICollisionEngine } from '../collision/engine';
|
|
3
|
+
import type { WordCloudFailureCache } from '../collision/failure-cache';
|
|
4
|
+
import type { IWordCloudShapeProfile } from '../shape/shape-profile';
|
|
5
|
+
import type { PlacementWordManager } from './placement-word-manager';
|
|
6
|
+
import type { IWordCloudLayoutConfig, IWordCloudLayoutGrid, IWordCloudLayoutRuntime, IWordCloudPlacement } from './types';
|
|
7
|
+
export interface IWordCloudPlacementContext {
|
|
8
|
+
readonly config: IWordCloudLayoutConfig;
|
|
9
|
+
readonly runtime: IWordCloudLayoutRuntime;
|
|
10
|
+
readonly grid: IWordCloudLayoutGrid;
|
|
11
|
+
readonly shapeGrid: Uint8Array;
|
|
12
|
+
readonly shapeProfile?: IWordCloudShapeProfile;
|
|
13
|
+
readonly collisionEngine: ICollisionEngine;
|
|
14
|
+
readonly wordManager?: PlacementWordManager;
|
|
15
|
+
readonly failureCache: WordCloudFailureCache;
|
|
16
|
+
readonly candidatePoints?: readonly ICollisionCandidate[];
|
|
17
|
+
readonly fineCandidatePoints?: readonly ICollisionCandidate[];
|
|
18
|
+
readonly stats?: IWordCloudLayoutStats;
|
|
19
|
+
}
|
|
20
|
+
export interface IWordCloudTryPlaceResult {
|
|
21
|
+
readonly placement?: IWordCloudPlacement;
|
|
22
|
+
readonly candidate?: ICollisionCandidate;
|
|
23
|
+
readonly tryCount: number;
|
|
24
|
+
readonly rejectByBounds: number;
|
|
25
|
+
readonly rejectByCollision: number;
|
|
26
|
+
readonly rejectByShape: number;
|
|
27
|
+
readonly exhausted: boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord } from '../../types';
|
|
2
|
+
import type { ICollisionEngine, ICollisionFootprint } from '../collision/engine';
|
|
3
|
+
import type { IPreparedWordCloudWord, IWordCloudLayoutConfig, IWordCloudLayoutRuntime } from './types';
|
|
4
|
+
export interface IResolvedPlacementWord {
|
|
5
|
+
readonly word: IWordCloudEncodedWord;
|
|
6
|
+
readonly footprint: ICollisionFootprint;
|
|
7
|
+
readonly rawWidth: number;
|
|
8
|
+
readonly rawHeight: number;
|
|
9
|
+
readonly fontSize: number;
|
|
10
|
+
readonly rotate: number;
|
|
11
|
+
}
|
|
12
|
+
export interface IPlacementWordSource {
|
|
13
|
+
resolve(): IResolvedPlacementWord;
|
|
14
|
+
}
|
|
15
|
+
export interface IPlacementWordSourceContext {
|
|
16
|
+
readonly config: IWordCloudLayoutConfig;
|
|
17
|
+
readonly runtime: IWordCloudLayoutRuntime;
|
|
18
|
+
readonly collisionEngine: ICollisionEngine;
|
|
19
|
+
}
|
|
20
|
+
export declare class PlacementWordManager {
|
|
21
|
+
private readonly _sources;
|
|
22
|
+
getWord(context: IPlacementWordSourceContext, word: IPreparedWordCloudWord): IPlacementWordSource;
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface IPickRotationDegOptions {
|
|
2
|
+
readonly angles: readonly unknown[];
|
|
3
|
+
readonly seed?: string | number;
|
|
4
|
+
readonly index?: number;
|
|
5
|
+
readonly key?: string;
|
|
6
|
+
readonly text?: string;
|
|
7
|
+
readonly ratio?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function pickRotationDeg(options: IPickRotationDegOptions): number;
|
|
10
|
+
export declare function normalizeRotationAngles(angles: readonly unknown[] | undefined): number[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IWordCloudBounds, IWordCloudEncodedWord } from '../../types';
|
|
2
|
+
import type { ICollisionCandidate, ICollisionEngine, ICollisionFootprint } from '../collision/engine';
|
|
3
|
+
import type { IWordCloudLayoutConfig, IWordCloudLayoutRuntime } from './types';
|
|
4
|
+
export declare function isCandidateInsideLayout(collisionEngine: ICollisionEngine, footprint: ICollisionFootprint, candidate: ICollisionCandidate, config: IWordCloudLayoutConfig): boolean;
|
|
5
|
+
export declare function runtimeMaskNeedsBounds(word: IWordCloudEncodedWord, runtime: IWordCloudLayoutRuntime, config: IWordCloudLayoutConfig): boolean;
|
|
6
|
+
export declare function isCandidateInsideRuntimeMask(word: IWordCloudEncodedWord, bounds: IWordCloudBounds, runtime: IWordCloudLayoutRuntime, config: IWordCloudLayoutConfig): boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IWordCloudTryPlaceResult } from './placement-types';
|
|
2
|
+
export interface IPlacementSearchPolicy {
|
|
3
|
+
readonly mandatoryFullSearchRank: number;
|
|
4
|
+
readonly middleFullPrimaryRank: number;
|
|
5
|
+
readonly stopTailRank: number;
|
|
6
|
+
readonly minCandidateBudget: number;
|
|
7
|
+
readonly recentWindowSize: number;
|
|
8
|
+
readonly skipConsecutiveFailureCount: number;
|
|
9
|
+
readonly stopConsecutiveFailureCount: number;
|
|
10
|
+
readonly skipRecentPlacedCount: number;
|
|
11
|
+
readonly stopRecentPlacedCount: number;
|
|
12
|
+
readonly skipPressure: number;
|
|
13
|
+
readonly stopPressure: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_PLACEMENT_SEARCH_POLICY: IPlacementSearchPolicy;
|
|
16
|
+
export declare enum PlacementSearchPlanAction {
|
|
17
|
+
Process = "process",
|
|
18
|
+
SkipWord = "skip-word",
|
|
19
|
+
StopTail = "stop-tail"
|
|
20
|
+
}
|
|
21
|
+
export type PlacementSearchPlan = {
|
|
22
|
+
readonly action: PlacementSearchPlanAction.Process;
|
|
23
|
+
readonly primaryLimit: number;
|
|
24
|
+
readonly fineLimit: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly action: PlacementSearchPlanAction.SkipWord;
|
|
27
|
+
readonly reason: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly action: PlacementSearchPlanAction.StopTail;
|
|
30
|
+
readonly reason: string;
|
|
31
|
+
};
|
|
32
|
+
export interface IPlacementSearchPlanInput {
|
|
33
|
+
readonly rank: number;
|
|
34
|
+
readonly primaryFullLimit: number;
|
|
35
|
+
readonly fineFullLimit: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class PlacementSearchPlanner {
|
|
38
|
+
private readonly _layoutArea;
|
|
39
|
+
private readonly _policy;
|
|
40
|
+
private _placedBoundsArea;
|
|
41
|
+
private _consecutiveFailureCount;
|
|
42
|
+
private readonly _recentResults;
|
|
43
|
+
constructor(_layoutArea: number, _policy?: IPlacementSearchPolicy);
|
|
44
|
+
createPlan(input: IPlacementSearchPlanInput): PlacementSearchPlan;
|
|
45
|
+
recordPlacementResult(result: IWordCloudTryPlaceResult): void;
|
|
46
|
+
private recordProcessPlan;
|
|
47
|
+
private getPressure;
|
|
48
|
+
private getRecentSuccessRate;
|
|
49
|
+
private getRecentPlacedCount;
|
|
50
|
+
private recordRecentResult;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from '../types/layout';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord } from '../../types';
|
|
2
|
+
import type { IPreparedWordCloudWord, IWordCloudLayoutConfig } from './types';
|
|
3
|
+
export declare function prepareWordCloudWords(words: readonly IWordCloudEncodedWord[], config: IWordCloudLayoutConfig): IPreparedWordCloudWord[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface IWordShrinkCandidate {
|
|
2
|
+
readonly designSize: number;
|
|
3
|
+
readonly actualSize: number;
|
|
4
|
+
readonly ratio: number;
|
|
5
|
+
readonly isDynamicShrink: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type WordShrinkCandidate = IWordShrinkCandidate;
|
|
8
|
+
export interface IWordShrinkStats {
|
|
9
|
+
readonly initialRatio: number;
|
|
10
|
+
readonly finalDynamicRatio: number;
|
|
11
|
+
readonly dynamicShrinkCount: number;
|
|
12
|
+
}
|
|
13
|
+
export type WordShrinkStats = IWordShrinkStats;
|
|
14
|
+
export interface IWordShrinkSessionOptions {
|
|
15
|
+
readonly initialRatio: number;
|
|
16
|
+
readonly fontSizeLimitMin: number;
|
|
17
|
+
readonly maxProbeCount?: number;
|
|
18
|
+
}
|
|
19
|
+
export type WordShrinkSessionOptions = IWordShrinkSessionOptions;
|
|
20
|
+
export declare const MAX_DYNAMIC_SHRINK_PROBE_COUNT = 16;
|
|
21
|
+
export declare class WordShrinkSession {
|
|
22
|
+
private readonly _initialRatio;
|
|
23
|
+
private readonly _fontSizeLimitMin;
|
|
24
|
+
private readonly _maxProbeCount;
|
|
25
|
+
private _dynamicRatio;
|
|
26
|
+
private _previousPlacedDesignSize;
|
|
27
|
+
private _previousPlacedActualSize;
|
|
28
|
+
private _dynamicShrinkCount;
|
|
29
|
+
constructor(options: WordShrinkSessionOptions);
|
|
30
|
+
resolveInitialCandidate(designSize: number): WordShrinkCandidate;
|
|
31
|
+
iterDynamicCandidates(params: {
|
|
32
|
+
readonly designSize: number;
|
|
33
|
+
readonly currentActualSize: number;
|
|
34
|
+
}): IterableIterator<WordShrinkCandidate>;
|
|
35
|
+
commitPlaced(candidate: WordShrinkCandidate): void;
|
|
36
|
+
getDynamicRatio(): number;
|
|
37
|
+
getStats(): WordShrinkStats;
|
|
38
|
+
}
|
|
39
|
+
export declare function resolveMinShrinkRatio(value: unknown, fallback: number): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IWordCloudMaskGrid, IWordCloudMaskShapeSpec, IWordCloudSegmentationResult, WordCloudShape } from '../../types';
|
|
2
|
+
export interface IWordCloudShapeGridOptions {
|
|
3
|
+
shapePaddingRatio?: number | null;
|
|
4
|
+
}
|
|
5
|
+
type BuiltinWordCloudShape = Exclude<WordCloudShape, 'cloud'>;
|
|
6
|
+
export declare function createMaskGridFromShape(shape: IWordCloudMaskShapeSpec | undefined, width: number, height: number, options?: IWordCloudShapeGridOptions): IWordCloudMaskGrid | undefined;
|
|
7
|
+
export declare function createBuiltinMaskGrid(shape: BuiltinWordCloudShape, width: number, height: number, options?: IWordCloudShapeGridOptions): IWordCloudMaskGrid;
|
|
8
|
+
export declare function createBuiltinMaskGrid(shape: WordCloudShape, width: number, height: number, options?: IWordCloudShapeGridOptions): IWordCloudMaskGrid | undefined;
|
|
9
|
+
export declare function createTextMaskGrid(shape: Extract<IWordCloudMaskShapeSpec, {
|
|
10
|
+
type: 'text';
|
|
11
|
+
}>, width: number, height: number): IWordCloudMaskGrid;
|
|
12
|
+
export declare function normalizeMaskGrid(grid: IWordCloudMaskGrid, width?: number, height?: number): IWordCloudMaskGrid;
|
|
13
|
+
export declare function segmentMaskGrid(maskGrid: IWordCloudMaskGrid): IWordCloudSegmentationResult;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IWordCloudLayoutOptions, IWordCloudMaskGrid, WordCloudShape } from '../../types';
|
|
2
|
+
import type { IWordCloudLayoutGrid, IWordCloudLayoutRuntime } from './types';
|
|
3
|
+
export interface IWordCloudShapeGridOptions {
|
|
4
|
+
sampleSize?: number;
|
|
5
|
+
insideRatio?: number;
|
|
6
|
+
shape?: WordCloudShape | string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createWordCloudShapeGrid(grid: IWordCloudLayoutGrid, maskGrid: IWordCloudMaskGrid | undefined, options?: IWordCloudShapeGridOptions): Uint8Array;
|
|
9
|
+
export declare function resolveWordCloudMaskGrid(grid: IWordCloudLayoutGrid, options: IWordCloudLayoutOptions, runtime: IWordCloudLayoutRuntime): IWordCloudMaskGrid | undefined;
|
|
10
|
+
export declare function getDefaultShapeSampleSize(shape: WordCloudShape | string | undefined, cellSize: number): number;
|
|
11
|
+
export declare function getDefaultShapeInsideRatio(shape: WordCloudShape | string | undefined): number;
|
|
12
|
+
export declare function getBuiltinShapeName(shape: IWordCloudLayoutOptions['maskShape'] | undefined): WordCloudShape | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WordCloudShape } from '../../types';
|
|
2
|
+
export interface IWordCloudShapeProfileOptions {
|
|
3
|
+
readonly shapePaddingRatio?: number | null;
|
|
4
|
+
readonly angleBins?: number | null;
|
|
5
|
+
}
|
|
6
|
+
export interface IWordCloudShapeProfile {
|
|
7
|
+
readonly shape: BuiltinWordCloudShape;
|
|
8
|
+
readonly width: number;
|
|
9
|
+
readonly height: number;
|
|
10
|
+
readonly center: readonly [number, number];
|
|
11
|
+
readonly maxRadius: number;
|
|
12
|
+
readonly radiusBins: readonly number[];
|
|
13
|
+
readonly cosBins: readonly number[];
|
|
14
|
+
readonly sinBins: readonly number[];
|
|
15
|
+
readonly contains: (x: number, y: number) => boolean;
|
|
16
|
+
readonly radiusAt: (theta: number) => number;
|
|
17
|
+
}
|
|
18
|
+
export type BuiltinWordCloudShape = Exclude<WordCloudShape, 'cloud'>;
|
|
19
|
+
export declare function createBuiltinShapeProfile(shape: BuiltinWordCloudShape, width: number, height: number, options?: IWordCloudShapeProfileOptions): IWordCloudShapeProfile;
|
|
20
|
+
export declare function createBuiltinShapeProfile(shape: WordCloudShape, width: number, height: number, options?: IWordCloudShapeProfileOptions): IWordCloudShapeProfile | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IWordCloudMaskGrid, IWordCloudTextSprite } from '../../types';
|
|
2
|
+
export interface ISpriteShapePlacement {
|
|
3
|
+
readonly sprite: Pick<IWordCloudTextSprite, 'width' | 'height' | 'pixels' | 'anchorX' | 'anchorY' | 'dpr' | 'textMetrics'>;
|
|
4
|
+
readonly shapeMask: Uint8Array;
|
|
5
|
+
readonly width: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
readonly left: number;
|
|
8
|
+
readonly top: number;
|
|
9
|
+
}
|
|
10
|
+
export interface IClippedSpriteToShape {
|
|
11
|
+
readonly sprite: IWordCloudTextSprite;
|
|
12
|
+
readonly left: number;
|
|
13
|
+
readonly top: number;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly alphaPixelCount: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function createShapeMask(maskGrid: IWordCloudMaskGrid | undefined, width: number, height: number): Uint8Array;
|
|
19
|
+
export declare function clipSpriteToShape(options: ISpriteShapePlacement): IClippedSpriteToShape | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from '../types/layout';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord, IWordCloudTextMeasurer } from '../../types';
|
|
2
|
+
export interface IMeasuredBoxWord {
|
|
3
|
+
readonly word: IWordCloudEncodedWord;
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function createPlacementLayoutWord(source: IWordCloudEncodedWord, fontSize: number, rotate: number, padding: number): IWordCloudEncodedWord;
|
|
8
|
+
export declare function measureBoxWord(source: IWordCloudEncodedWord, measurer: IWordCloudTextMeasurer, fontSize: number, rotate: number, padding: number): IMeasuredBoxWord;
|