@univerjs-pro/engine-shape 0.18.0 → 0.19.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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/render-engine/sketch-stroke-renderer.d.ts +79 -0
- package/lib/types/shape-enum.d.ts +15 -0
- package/lib/types/shape-type.d.ts +6 -1
- package/lib/types/util/shape-util.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BasicShapeModel as ShapeModel } from '../src/model/shape-model';
|
|
2
2
|
export { LineShapeRenderModel } from '../src/render-engine/line-shape-render-model';
|
|
3
3
|
export { BaseShapeRenderModel } from '../src/render-engine/shape-render-model';
|
|
4
|
-
export { BasicShapeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeTypeEnum } from '../src/shape-enum';
|
|
4
|
+
export { BasicShapeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum } from '../src/shape-enum';
|
|
5
5
|
export type { IConnectorLayoutResult, IConnectorRouteLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, IGdContextBase, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItem, IShapeAdjustItemResolved, IShapeContextOptions, IBasicShapeData as IShapeData, IShapeHitTestResult, IShapeJSONData, IShapeLineStyle, IShapeModel, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeText, ShapeAdjustHandleTypeEnum, ShapeHitTestHitTypeEnum, } from '../src/shape-type';
|
|
6
6
|
export { AccentBorderCallout1Shape } from '../src/shapes/accent-border-callout1-shape';
|
|
7
7
|
export { AccentBorderCallout2Shape } from '../src/shapes/accent-border-callout2-shape';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ShapeSketchTypeEnum } from '../shape-enum';
|
|
2
|
+
/**
|
|
3
|
+
* Resolved (numeric) path command after gd evaluation and scaling.
|
|
4
|
+
* Used by SketchStrokeRenderer to draw sketch-style strokes.
|
|
5
|
+
*/
|
|
6
|
+
export type IResolvedPathCommand = {
|
|
7
|
+
cmd: 'M';
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
} | {
|
|
11
|
+
cmd: 'L';
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
} | {
|
|
15
|
+
cmd: 'C';
|
|
16
|
+
cp1x: number;
|
|
17
|
+
cp1y: number;
|
|
18
|
+
cp2x: number;
|
|
19
|
+
cp2y: number;
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
} | {
|
|
23
|
+
cmd: 'Q';
|
|
24
|
+
cpx: number;
|
|
25
|
+
cpy: number;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
} | {
|
|
29
|
+
cmd: 'A';
|
|
30
|
+
centerX: number;
|
|
31
|
+
centerY: number;
|
|
32
|
+
wR: number;
|
|
33
|
+
hR: number;
|
|
34
|
+
startAngle: number;
|
|
35
|
+
endAngle: number;
|
|
36
|
+
anticlockwise: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
cmd: 'z';
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Renders shape stroke with a hand-drawn / sketch visual effect.
|
|
42
|
+
*
|
|
43
|
+
* All sketch-related rendering logic lives here. The caller is responsible
|
|
44
|
+
* for setting strokeStyle, lineWidth, lineDash, lineJoin, lineCap on the
|
|
45
|
+
* canvas context *before* calling render().
|
|
46
|
+
*/
|
|
47
|
+
export declare class SketchStrokeRenderer {
|
|
48
|
+
/**
|
|
49
|
+
* Build and stroke a sketch-style path on `ctx`.
|
|
50
|
+
*
|
|
51
|
+
* @param ctx Canvas rendering context (strokeStyle etc. should already be configured)
|
|
52
|
+
* @param commands The resolved (numeric) path commands that describe the original shape outline
|
|
53
|
+
* @param sketchType Which sketch mode to apply
|
|
54
|
+
* @param seed Integer seed for the seeded RNG – same seed produces identical output
|
|
55
|
+
*/
|
|
56
|
+
static render(ctx: CanvasRenderingContext2D, commands: IResolvedPathCommand[], sketchType: ShapeSketchTypeEnum, seed: number): void;
|
|
57
|
+
private static _renderPass;
|
|
58
|
+
/**
|
|
59
|
+
* Draw a sketchy straight line from (x0,y0) to (x1,y1).
|
|
60
|
+
*
|
|
61
|
+
* The line is split into sub-segments. Each interior split point is
|
|
62
|
+
* displaced perpendicularly by a seeded-random amount. The resulting
|
|
63
|
+
* noisy chain is smoothed with a chain of quadratic bezier curves so the
|
|
64
|
+
* output looks like a natural hand-drawn stroke rather than a polygon.
|
|
65
|
+
*/
|
|
66
|
+
private static _sketchLine;
|
|
67
|
+
/**
|
|
68
|
+
* Draw a sketchy cubic bezier by perturbing the control points.
|
|
69
|
+
*/
|
|
70
|
+
private static _sketchCubic;
|
|
71
|
+
/**
|
|
72
|
+
* Draw a sketchy quadratic bezier by perturbing the control point.
|
|
73
|
+
*/
|
|
74
|
+
private static _sketchQuadratic;
|
|
75
|
+
/**
|
|
76
|
+
* Draw a sketchy ellipse arc by applying slight noise to the center and radii.
|
|
77
|
+
*/
|
|
78
|
+
private static _sketchArc;
|
|
79
|
+
}
|
|
@@ -319,3 +319,18 @@ export declare enum ShapeArrowSizeEnum {
|
|
|
319
319
|
Medium = 2,
|
|
320
320
|
Large = 3
|
|
321
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Shape sketch (hand-drawn) style enum.
|
|
324
|
+
* Controls how strongly the stroke is perturbed to look like a hand-drawn line.
|
|
325
|
+
*
|
|
326
|
+
* - None – regular vector stroke, no perturbation
|
|
327
|
+
* - Curved – very slight smooth waviness
|
|
328
|
+
* - Freehand – moderate irregular deformation
|
|
329
|
+
* - HandDrawn – heavy rough deformation rendered in two overlapping passes
|
|
330
|
+
*/
|
|
331
|
+
export declare enum ShapeSketchTypeEnum {
|
|
332
|
+
None = 0,
|
|
333
|
+
Curved = 1,
|
|
334
|
+
Freehand = 2,
|
|
335
|
+
HandDrawn = 3
|
|
336
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BasicShapeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeTypeEnum } from './shape-enum';
|
|
1
|
+
import type { BasicShapeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum } from './shape-enum';
|
|
2
2
|
/**
|
|
3
3
|
* GdContext 用来计算 OOXML Shape 的 Geometry Definitions (gd)
|
|
4
4
|
* 包含:
|
|
@@ -746,6 +746,7 @@ export interface IShapeRenderParameters {
|
|
|
746
746
|
flipH?: boolean;
|
|
747
747
|
flipV?: boolean;
|
|
748
748
|
angle?: number;
|
|
749
|
+
oKey: string;
|
|
749
750
|
}
|
|
750
751
|
export interface IShapeRelationItem {
|
|
751
752
|
shapeId: string;
|
|
@@ -768,6 +769,10 @@ export interface IShapeLineStyle {
|
|
|
768
769
|
capType?: ShapeLineCapEnum;
|
|
769
770
|
lineJoinType?: ShapeLineJoinEnum;
|
|
770
771
|
lineStrokeType?: ShapeLineTypeEnum;
|
|
772
|
+
/**
|
|
773
|
+
* Hand-drawn / sketch style. Defaults to `ShapeSketchTypeEnum.None`.
|
|
774
|
+
*/
|
|
775
|
+
sketchType?: ShapeSketchTypeEnum;
|
|
771
776
|
}
|
|
772
777
|
export interface IShapeModel {
|
|
773
778
|
getBasicShapeType(): BasicShapeEnum;
|
|
@@ -6,3 +6,4 @@ import { ShapeTypeEnum } from '../shape-enum';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isConnectorShape(shapeType: ShapeTypeEnum): boolean;
|
|
8
8
|
export declare function isCurvedConnectorShape(shapeType: ShapeTypeEnum): boolean;
|
|
9
|
+
export declare function getSketchSeed(shapeId: string): number;
|