locusing 0.1.0 → 0.1.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/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import Matter from 'matter-js';
2
+
1
3
  /**
2
4
  * @locusing/math - 数学工具库
3
5
  *
@@ -17,6 +19,42 @@ declare const UL: Vector2;
17
19
  declare const UR: Vector2;
18
20
  declare const DL: Vector2;
19
21
  declare const DR: Vector2;
22
+ /**
23
+ * Manim 风格方向常量(数学坐标系,Y 向上为正)
24
+ *
25
+ * 用于 Frame 模式渲染,原点在画布中心
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { Dir, scale } from 'locusing';
30
+ *
31
+ * // 正方形向上移动 2 单位
32
+ * square(1).move(scale(Dir.UP, 2));
33
+ *
34
+ * // 圆形在右下角
35
+ * circle(0.5).move(scale(Dir.DR, 3));
36
+ * ```
37
+ */
38
+ declare const Dir: {
39
+ /** 原点 [0, 0] */
40
+ ORIGIN: Vector2;
41
+ /** 向上 [0, 1] */
42
+ UP: Vector2;
43
+ /** 向下 [0, -1] */
44
+ DOWN: Vector2;
45
+ /** 向左 [-1, 0] */
46
+ LEFT: Vector2;
47
+ /** 向右 [1, 0] */
48
+ RIGHT: Vector2;
49
+ /** 左上 [-1, 1] */
50
+ UL: Vector2;
51
+ /** 右上 [1, 1] */
52
+ UR: Vector2;
53
+ /** 左下 [-1, -1] */
54
+ DL: Vector2;
55
+ /** 右下 [1, -1] */
56
+ DR: Vector2;
57
+ };
20
58
  declare function add(a: Vector2, b: Vector2): Vector2;
21
59
  declare function sub(a: Vector2, b: Vector2): Vector2;
22
60
  declare function mul(v: Vector2, scalar: number): Vector2;
@@ -24,7 +62,7 @@ declare function div(v: Vector2, scalar: number): Vector2;
24
62
  declare function dot$1(a: Vector2, b: Vector2): number;
25
63
  declare function cross(a: Vector2, b: Vector2): number;
26
64
  declare function length(v: Vector2): number;
27
- declare function normalize(v: Vector2): Vector2;
65
+ declare function normalize$1(v: Vector2): Vector2;
28
66
  declare function distance(a: Vector2, b: Vector2): number;
29
67
  declare function angle(v: Vector2): number;
30
68
  declare function angleBetween(a: Vector2, b: Vector2): number;
@@ -75,6 +113,39 @@ declare const easing: {
75
113
  easeOutElastic: (t: number) => number;
76
114
  easeInBounce: (t: number) => number;
77
115
  easeOutBounce: (t: number) => number;
116
+ /**
117
+ * thereAndBack - 去而复返
118
+ *
119
+ * 从 0 开始,到 0.5 时达到 1,然后回到 0
120
+ */
121
+ thereAndBack: (t: number) => number;
122
+ /**
123
+ * thereAndBackWithPause - 去而复返(带停顿)
124
+ *
125
+ * 类似 thereAndBack,但在中间有一段停留时间
126
+ * @param pauseRatio - 停顿占总时间的比例,默认 1/3
127
+ */
128
+ thereAndBackWithPause: (t: number, pauseRatio?: number) => number;
129
+ /**
130
+ * runningStart - 起跑式
131
+ *
132
+ * 先后退一点,再向前冲(类似起跑动作)
133
+ * @param pullFactor - 后退程度,默认 -0.3
134
+ */
135
+ runningStart: (t: number, pullFactor?: number) => number;
136
+ /**
137
+ * wiggle - 摇摆
138
+ *
139
+ * 产生摇摆效果,适合强调动画
140
+ */
141
+ wiggle: (t: number, wiggles?: number) => number;
142
+ /**
143
+ * exponentialDecay - 指数衰减
144
+ *
145
+ * 快速到达目标后缓慢稳定
146
+ * @param halfLife - 半衰期,值越小衰减越快,默认 0.1
147
+ */
148
+ exponentialDecay: (t: number, halfLife?: number) => number;
78
149
  };
79
150
  declare const PI: number;
80
151
  declare const TAU: number;
@@ -108,7 +179,7 @@ interface TextStyle extends Style {
108
179
  textAnchor?: 'start' | 'middle' | 'end';
109
180
  dominantBaseline?: 'auto' | 'middle' | 'hanging' | 'central';
110
181
  }
111
- type ShapeType = 'group' | 'path' | 'rect' | 'circle' | 'ellipse' | 'line' | 'polyline' | 'polygon' | 'text' | 'arc';
182
+ type ShapeType = 'group' | 'path' | 'rect' | 'circle' | 'ellipse' | 'line' | 'polyline' | 'polygon' | 'text' | 'arc' | 'tex';
112
183
  type PathCommand = {
113
184
  type: 'M';
114
185
  x: number;
@@ -231,11 +302,41 @@ interface ArcShape extends BaseShape {
231
302
  startAngle: number;
232
303
  endAngle: number;
233
304
  }
234
- type Shape = GroupShape | PathShape | RectShape | CircleShape | EllipseShape | LineShape | PolylineShape | PolygonShape | TextShape | ArcShape;
305
+ interface TexShape extends BaseShape {
306
+ type: 'tex';
307
+ x: number;
308
+ y: number;
309
+ latex: string;
310
+ html: string;
311
+ fontSize: number;
312
+ color: string;
313
+ }
314
+ type Shape = GroupShape | PathShape | RectShape | CircleShape | EllipseShape | LineShape | PolylineShape | PolygonShape | TextShape | ArcShape | TexShape;
315
+ interface FrameConfig {
316
+ /** 逻辑宽度(默认 16) */
317
+ width: number;
318
+ /** 逻辑高度(默认 9,16:9 比例) */
319
+ height: number;
320
+ }
235
321
  interface RenderOptions {
322
+ /** 画布像素宽度 */
236
323
  width?: number;
324
+ /** 画布像素高度 */
237
325
  height?: number;
326
+ /** 背景颜色 */
238
327
  background?: string;
328
+ /**
329
+ * Frame 配置(Manim 风格坐标系)
330
+ *
331
+ * 启用后:
332
+ * - 原点在画布中心
333
+ * - Y 轴向上为正
334
+ * - 图形使用逻辑坐标,自动映射到像素
335
+ *
336
+ * 可以是 boolean(使用默认 16:9 frame)或 FrameConfig 对象
337
+ */
338
+ frame?: boolean | FrameConfig;
339
+ /** 手绘风格 */
239
340
  rough?: boolean;
240
341
  roughness?: number;
241
342
  bowing?: number;
@@ -295,6 +396,46 @@ declare class Diagram {
295
396
  /** 移动到指定位置 */
296
397
  position(x: number, y: number): Diagram;
297
398
  position(v: Vector2): Diagram;
399
+ /**
400
+ * 移动图形(Manim 风格)
401
+ *
402
+ * 将图形中心移动到指定位置。与 position() 相同,
403
+ * 但命名更符合 Manim 习惯。
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * import { square, Dir, mul } from 'locusing';
408
+ *
409
+ * // 移动到 (2, 3)
410
+ * square(1).move([2, 3]);
411
+ *
412
+ * // 使用方向常量
413
+ * square(1).move(mul(Dir.UP, 2)); // 向上移动 2 单位
414
+ * square(1).move(mul(Dir.RIGHT, 3)); // 向右移动 3 单位
415
+ *
416
+ * // 组合方向
417
+ * import { add } from 'locusing';
418
+ * square(1).move(add(mul(Dir.UP, 2), mul(Dir.RIGHT, 3))); // 右上方
419
+ * ```
420
+ */
421
+ move(x: number, y: number): Diagram;
422
+ move(v: Vector2): Diagram;
423
+ /**
424
+ * 相对移动(偏移)
425
+ *
426
+ * 将图形从当前位置移动指定偏移量。
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * // 向右偏移 2 单位
431
+ * square(1).shift([2, 0]);
432
+ *
433
+ * // 使用方向常量
434
+ * square(1).shift(mul(Dir.UP, 1.5));
435
+ * ```
436
+ */
437
+ shift(x: number, y: number): Diagram;
438
+ shift(v: Vector2): Diagram;
298
439
  /** 旋转(弧度) */
299
440
  rotate(radians: number, center?: Vector2): Diagram;
300
441
  /** 旋转(度数) */
@@ -310,6 +451,8 @@ declare class Diagram {
310
451
  add(...others: Diagram[]): Diagram;
311
452
  /** 获取中心点 */
312
453
  center(): Vector2;
454
+ /** Manim 风格别名:获取中心点 */
455
+ getCenter(): Vector2;
313
456
  /** 获取包围盒 */
314
457
  bounds(): {
315
458
  x: number;
@@ -317,10 +460,73 @@ declare class Diagram {
317
460
  width: number;
318
461
  height: number;
319
462
  };
463
+ /** 获取宽度 */
464
+ width(): number;
465
+ /** Manim 风格别名:获取宽度 */
466
+ getWidth(): number;
467
+ /** 获取高度 */
468
+ height(): number;
469
+ /** Manim 风格别名:获取高度 */
470
+ getHeight(): number;
471
+ /** 获取左边缘 x 坐标 */
472
+ getLeft(): number;
473
+ /** 获取右边缘 x 坐标 */
474
+ getRight(): number;
475
+ /** 获取上边缘 y 坐标 */
476
+ getTop(): number;
477
+ /** 获取下边缘 y 坐标 */
478
+ getBottom(): number;
479
+ /** 获取左边缘点 */
480
+ getLeftEdge(): Vector2;
481
+ /** 获取右边缘点 */
482
+ getRightEdge(): Vector2;
483
+ /** 获取上边缘点 */
484
+ getTopEdge(): Vector2;
485
+ /** 获取下边缘点 */
486
+ getBottomEdge(): Vector2;
320
487
  /** 获取指定方向的边缘点 */
321
488
  edge(direction: Vector2): Vector2;
322
489
  /** 获取相对于另一个图形的位置 */
323
490
  nextTo(other: Diagram, direction: Vector2, buffer?: number): Diagram;
491
+ /**
492
+ * 获取子对象列表
493
+ *
494
+ * Manim 风格:返回直接子对象的 Diagram 数组
495
+ */
496
+ get submobjects(): Diagram[];
497
+ /**
498
+ * 获取所有后代对象(包括自身)
499
+ *
500
+ * Manim 风格:递归获取所有子对象
501
+ */
502
+ getFamily(): Diagram[];
503
+ /**
504
+ * 获取所有后代对象(不包括自身)
505
+ */
506
+ getFamilyWithoutSelf(): Diagram[];
507
+ /**
508
+ * 按索引获取子对象
509
+ */
510
+ getSubmobjectAt(index: number): Diagram | undefined;
511
+ /**
512
+ * 获取子对象数量
513
+ */
514
+ get length(): number;
515
+ /**
516
+ * 对所有子对象应用变换
517
+ */
518
+ applyToFamily(fn: (diagram: Diagram) => Diagram): Diagram;
519
+ /**
520
+ * 将图形中心对齐到原点
521
+ */
522
+ centerOnOrigin(): Diagram;
523
+ /**
524
+ * 将图形对齐到另一个图形的指定边缘
525
+ *
526
+ * @param other - 参考图形
527
+ * @param direction - 对齐方向
528
+ */
529
+ alignTo(other: Diagram, direction: Vector2): Diagram;
324
530
  /** 克隆图形 */
325
531
  clone(): Diagram;
326
532
  /** 复制到指定位置 */
@@ -333,7 +539,16 @@ declare class Diagram {
333
539
  * 提供 square, circle, line, polygon, text 等图元创建函数
334
540
  */
335
541
 
336
- /** 创建矩形 */
542
+ /**
543
+ * 创建矩形
544
+ *
545
+ * @param width 宽度
546
+ * @param height 高度
547
+ * @param options 可选配置
548
+ * @param options.rx 圆角 X 半径(默认 0)
549
+ * @param options.ry 圆角 Y 半径(默认 0)
550
+ * @param options.centered 是否以原点居中(默认 true)
551
+ */
337
552
  declare function rect(width: number, height: number, options?: {
338
553
  rx?: number;
339
554
  ry?: number;
@@ -348,11 +563,24 @@ declare function square(size: number, options?: {
348
563
  declare function circle(radius: number): Diagram;
349
564
  /** 创建椭圆 */
350
565
  declare function ellipse(rx: number, ry: number): Diagram;
351
- /** 创建点(小圆) */
566
+ /**
567
+ * 创建点(小圆)
568
+ *
569
+ * @param position 位置(默认 `[0, 0]`)
570
+ * @param radius 半径(默认 `4`)
571
+ */
352
572
  declare function dot(position?: Vector2, radius?: number): Diagram;
353
573
  /** 创建直线 */
354
574
  declare function line(from: Vector2, to: Vector2): Diagram;
355
- /** 创建箭头 */
575
+ /**
576
+ * 创建箭头
577
+ *
578
+ * @param from 起点 `[x, y]`
579
+ * @param to 终点 `[x, y]`
580
+ * @param options 可选配置
581
+ * @param options.headSize 箭头大小(默认 `10`)
582
+ * @param options.headAngle 箭头角度(默认 `PI / 6`)
583
+ */
356
584
  declare function arrow(from: Vector2, to: Vector2, options?: {
357
585
  headSize?: number;
358
586
  headAngle?: number;
@@ -378,6 +606,322 @@ declare function polyline(...points: Vector2[]): Diagram;
378
606
  declare function arc(radius: number, startAngle: number, endAngle: number): Diagram;
379
607
  /** 创建扇形 */
380
608
  declare function sector(radius: number, startAngle: number, endAngle: number): Diagram;
609
+ /**
610
+ * 创建环形扇区(AnnularSector)
611
+ *
612
+ * 环形扇区是由两个同心圆弧和两条半径线围成的区域。
613
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.AnnularSector.html
614
+ *
615
+ * @param innerRadius - 内半径
616
+ * @param outerRadius - 外半径
617
+ * @param startAngle - 起始角度(弧度)
618
+ * @param endAngle - 结束角度(弧度)
619
+ * @returns Diagram 对象
620
+ *
621
+ * @example
622
+ * ```typescript
623
+ * // 创建一个 90 度的环形扇区
624
+ * const sector = annularSector(50, 100, 0, Math.PI / 2)
625
+ * .fill('#58C4DD')
626
+ * .stroke('#FFFFFF');
627
+ * ```
628
+ */
629
+ declare function annularSector(innerRadius: number, outerRadius: number, startAngle: number, endAngle: number): Diagram;
630
+ /**
631
+ * 创建圆环(Annulus)
632
+ *
633
+ * 圆环是由两个同心圆围成的环形区域。
634
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.Annulus.html
635
+ *
636
+ * @param innerRadius - 内半径
637
+ * @param outerRadius - 外半径
638
+ * @returns Diagram 对象
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * // 创建一个圆环
643
+ * const ring = annulus(50, 100)
644
+ * .fill('#FC6255')
645
+ * .stroke('none');
646
+ * ```
647
+ */
648
+ declare function annulus(innerRadius: number, outerRadius: number): Diagram;
649
+ /**
650
+ * 创建两点间的弧线(ArcBetweenPoints)
651
+ *
652
+ * 在两点之间创建一条弧线,通过指定弧度来控制弧线的弯曲程度。
653
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.ArcBetweenPoints.html
654
+ *
655
+ * @param start - 起点坐标
656
+ * @param end - 终点坐标
657
+ * @param arcAngle - 弧线弯曲的角度(弧度),正值向左弯曲,负值向右弯曲
658
+ * @returns Diagram 对象
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * // 创建一条向上弯曲的弧线
663
+ * const arc = arcBetweenPoints([0, 0], [200, 0], Math.PI / 3)
664
+ * .stroke('#58C4DD')
665
+ * .strokeWidth(2);
666
+ * ```
667
+ */
668
+ declare function arcBetweenPoints(start: Vector2, end: Vector2, arcAngle?: number): Diagram;
669
+ /**
670
+ * 创建向量(Vector)
671
+ *
672
+ * 向量是从原点或指定起点出发的带箭头的线段。
673
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.Vector.html
674
+ *
675
+ * @param direction - 向量的方向和大小(相对于起点的偏移)
676
+ * @param options - 可选配置
677
+ * @param options.origin - 向量起点,默认为原点 [0, 0]
678
+ * @param options.color - 向量颜色,默认为黄色 '#FFFF00'
679
+ * @param options.headSize - 箭头大小,默认为 10
680
+ * @param options.headAngle - 箭头角度,默认为 PI/6
681
+ * @param options.strokeWidth - 线条宽度,默认为 3
682
+ * @returns Diagram 对象
683
+ *
684
+ * @example
685
+ * ```typescript
686
+ * // 创建一个从原点指向 (100, 50) 的黄色向量
687
+ * const v = vector([100, 50]);
688
+ *
689
+ * // 创建一个从 (50, 50) 出发的红色向量
690
+ * const v2 = vector([80, 40], { origin: [50, 50], color: '#FC6255' });
691
+ * ```
692
+ */
693
+ declare function vector(direction: Vector2, options?: {
694
+ origin?: Vector2;
695
+ color?: string;
696
+ headSize?: number;
697
+ headAngle?: number;
698
+ strokeWidth?: number;
699
+ }): Diagram;
700
+ /**
701
+ * 创建两点间的花括号(BraceBetweenPoints)
702
+ *
703
+ * 在两点之间创建一个装饰性的花括号形状。
704
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.svg.brace.Brace.html
705
+ *
706
+ * @param start - 起点坐标
707
+ * @param end - 终点坐标
708
+ * @param options - 可选配置
709
+ * @param options.direction - 花括号朝向的方向向量,正值表示垂直于连线向外
710
+ * @param options.sharpness - 花括号尖锐程度,值越大越尖锐,默认 0.3
711
+ * @param options.tipExtent - 中间尖端的伸出程度,默认 0.2
712
+ * @returns Diagram 对象
713
+ *
714
+ * @example
715
+ * ```typescript
716
+ * // 在两点之间创建一个向下的花括号
717
+ * const br = braceBetweenPoints([100, 150], [300, 150])
718
+ * .stroke('#FFFF00')
719
+ * .strokeWidth(2);
720
+ * ```
721
+ */
722
+ declare function braceBetweenPoints(start: Vector2, end: Vector2, options?: {
723
+ direction?: number;
724
+ sharpness?: number;
725
+ tipExtent?: number;
726
+ }): Diagram;
727
+ /**
728
+ * 创建花括号(Brace)
729
+ *
730
+ * 为一个图形对象或两点区间创建装饰性的花括号。
731
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.svg.brace.Brace.html
732
+ *
733
+ * @param target - 目标图形或两点数组
734
+ * @param options - 可选配置
735
+ * @param options.direction - 花括号朝向,可以是 'UP', 'DOWN', 'LEFT', 'RIGHT' 或自定义向量
736
+ * @param options.sharpness - 花括号尖锐程度
737
+ * @param options.buff - 与目标的间距
738
+ * @returns Diagram 对象
739
+ *
740
+ * @example
741
+ * ```typescript
742
+ * // 为方块底部添加花括号
743
+ * const sq = square(100).translate(200, 150);
744
+ * const br = brace(sq, { direction: 'DOWN' }).stroke('#FFFF00');
745
+ * ```
746
+ */
747
+ declare function brace(target: Diagram | [Vector2, Vector2], options?: {
748
+ direction?: Vector2 | 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';
749
+ sharpness?: number;
750
+ buff?: number;
751
+ }): Diagram;
752
+ /**
753
+ * 创建带标签的花括号(BraceLabel)
754
+ *
755
+ * 花括号加上在尖端位置的文本标签。
756
+ *
757
+ * @param target - 目标图形或两点数组
758
+ * @param label - 标签文本
759
+ * @param options - 可选配置
760
+ * @param options.direction - 花括号朝向
761
+ * @param options.fontSize - 标签字体大小
762
+ * @param options.labelColor - 标签颜色
763
+ * @param options.sharpness - 花括号尖锐程度
764
+ * @param options.buff - 与目标的间距
765
+ * @param options.labelBuff - 标签与花括号尖端的间距
766
+ * @returns Diagram 对象
767
+ *
768
+ * @example
769
+ * ```typescript
770
+ * // 为方块添加带标签的花括号
771
+ * const sq = square(100).translate(200, 150);
772
+ * const bl = braceLabel(sq, 'width', { direction: 'DOWN' });
773
+ * ```
774
+ */
775
+ declare function braceLabel(target: Diagram | [Vector2, Vector2], label: string, options?: {
776
+ direction?: Vector2 | 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';
777
+ fontSize?: number;
778
+ labelColor?: string;
779
+ sharpness?: number;
780
+ buff?: number;
781
+ labelBuff?: number;
782
+ }): Diagram;
783
+ /**
784
+ * 创建带标签的点(LabeledDot)
785
+ *
786
+ * 在指定位置创建一个带有文本标签的圆点。
787
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.LabeledDot.html
788
+ *
789
+ * @param label - 标签文本
790
+ * @param position - 点的位置,默认为原点
791
+ * @param options - 可选配置
792
+ * @param options.radius - 点的半径,如不指定则根据标签大小自动计算
793
+ * @param options.fontSize - 标签字体大小
794
+ * @param options.dotColor - 点的填充颜色
795
+ * @param options.labelColor - 标签颜色
796
+ * @returns Diagram 对象
797
+ *
798
+ * @example
799
+ * ```typescript
800
+ * // 创建一个标签为 "A" 的点
801
+ * const dotA = labeledDot('A', [100, 100]);
802
+ *
803
+ * // 创建一个自定义颜色的标签点
804
+ * const dotB = labeledDot('B', [200, 100], {
805
+ * dotColor: '#FC6255',
806
+ * labelColor: '#FFFFFF'
807
+ * });
808
+ * ```
809
+ */
810
+ declare function labeledDot(label: string, position?: Vector2, options?: {
811
+ radius?: number;
812
+ fontSize?: number;
813
+ dotColor?: string;
814
+ labelColor?: string;
815
+ }): Diagram;
816
+ /**
817
+ * 创建弯曲箭头(CurvedArrow)
818
+ *
819
+ * 在两点之间创建一条弯曲的箭头。
820
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.CurvedArrow.html
821
+ *
822
+ * @param start - 起点坐标
823
+ * @param end - 终点坐标
824
+ * @param options - 可选配置
825
+ * @param options.angle - 弧线弯曲角度,默认 PI/4
826
+ * @param options.headSize - 箭头大小,默认 10
827
+ * @param options.headAngle - 箭头张角,默认 PI/6
828
+ * @param options.color - 颜色,默认灰色
829
+ * @param options.strokeWidth - 线条宽度,默认 2
830
+ * @returns Diagram 对象
831
+ *
832
+ * @example
833
+ * ```typescript
834
+ * // 创建弯曲箭头
835
+ * const arrow = curvedArrow([100, 150], [300, 150])
836
+ * .stroke('#58C4DD');
837
+ * ```
838
+ */
839
+ declare function curvedArrow(start: Vector2, end: Vector2, options?: {
840
+ angle?: number;
841
+ headSize?: number;
842
+ headAngle?: number;
843
+ color?: string;
844
+ strokeWidth?: number;
845
+ }): Diagram;
846
+ /**
847
+ * 创建弯曲双向箭头(CurvedDoubleArrow)
848
+ *
849
+ * 在两点之间创建一条两端都有箭头的弯曲线。
850
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.CurvedDoubleArrow.html
851
+ *
852
+ * @param start - 起点坐标
853
+ * @param end - 终点坐标
854
+ * @param options - 可选配置
855
+ * @param options.angle - 弧线弯曲角度,默认 PI/4
856
+ * @param options.headSize - 箭头大小,默认 10
857
+ * @param options.headAngle - 箭头张角,默认 PI/6
858
+ * @param options.color - 颜色,默认灰色
859
+ * @param options.strokeWidth - 线条宽度,默认 2
860
+ * @returns Diagram 对象
861
+ *
862
+ * @example
863
+ * ```typescript
864
+ * // 创建弯曲双向箭头
865
+ * const arrow = curvedDoubleArrow([100, 150], [300, 150])
866
+ * .stroke('#FC6255');
867
+ * ```
868
+ */
869
+ declare function curvedDoubleArrow(start: Vector2, end: Vector2, options?: {
870
+ angle?: number;
871
+ headSize?: number;
872
+ headAngle?: number;
873
+ color?: string;
874
+ strokeWidth?: number;
875
+ }): Diagram;
876
+ /**
877
+ * 创建肘形线(Elbow)
878
+ *
879
+ * 创建一个 L 形状的直角转折线,常用于标记直角。
880
+ * 参考 Manim: https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.Elbow.html
881
+ *
882
+ * @param width - 肘形线的宽度(两边长度)
883
+ * @param options - 可选配置
884
+ * @param options.angle - 旋转角度,默认 0(水平向右,垂直向上)
885
+ * @returns Diagram 对象
886
+ *
887
+ * @example
888
+ * ```typescript
889
+ * // 创建默认肘形线
890
+ * const elb = elbow(20).translate(100, 100);
891
+ *
892
+ * // 创建旋转 45 度的肘形线
893
+ * const elb2 = elbow(20, { angle: Math.PI / 4 });
894
+ * ```
895
+ */
896
+ declare function elbow(width: number, options?: {
897
+ angle?: number;
898
+ }): Diagram;
899
+ /**
900
+ * 创建切线(TangentLine)
901
+ *
902
+ * 这是一个简化版的切线实现,用于在指定点创建一条切线。
903
+ * 由于完整的切线需要对曲线求导,这里提供一个基于两点的简化版本。
904
+ *
905
+ * @param point - 切点坐标
906
+ * @param direction - 切线方向向量
907
+ * @param options - 可选配置
908
+ * @param options.length - 切线长度,默认 100
909
+ * @param options.centered - 是否以切点为中心,默认 true
910
+ * @returns Diagram 对象
911
+ *
912
+ * @example
913
+ * ```typescript
914
+ * // 创建一条水平切线
915
+ * const tangent = tangentLine([200, 150], [1, 0], { length: 80 });
916
+ *
917
+ * // 创建一条 45 度切线
918
+ * const tangent2 = tangentLine([200, 150], [1, -1], { length: 60 });
919
+ * ```
920
+ */
921
+ declare function tangentLine(point: Vector2, direction: Vector2, options?: {
922
+ length?: number;
923
+ centered?: boolean;
924
+ }): Diagram;
381
925
  /** 创建路径 */
382
926
  declare function path(commands: PathCommand[]): Diagram;
383
927
  /** 从 SVG 路径字符串创建 */
@@ -390,46 +934,256 @@ declare function text(content: string, options?: {
390
934
  fontStyle?: string;
391
935
  anchor?: 'start' | 'middle' | 'end';
392
936
  }): Diagram;
393
- /** 创建 LaTeX 公式(占位符,需要 MathJax 支持) */
937
+ /** 创建 LaTeX 公式 */
394
938
  declare function tex(latex: string, options?: {
395
939
  fontSize?: number;
940
+ color?: string;
396
941
  }): Diagram;
397
- /** 组合多个图形 */
398
- declare function combine(...diagrams: Diagram[]): Diagram;
399
- /** 创建空组 */
400
- declare function group(): Diagram;
401
-
402
942
  /**
403
- * @locusing/core - SVG 渲染器
943
+ * 创建段落文本(Paragraph)
404
944
  *
405
- * 将 Diagram 渲染为 SVG 元素
945
+ * 创建多行文本,支持对齐方式和行高设置。
946
+ *
947
+ * @param lines - 文本行数组
948
+ * @param options - 可选配置
949
+ * @param options.alignment - 对齐方式:'left', 'center', 'right'
950
+ * @param options.lineHeight - 行高倍数,默认 1.4
951
+ * @param options.fontSize - 字体大小
952
+ * @param options.fontFamily - 字体
953
+ * @returns Diagram 对象
954
+ *
955
+ * @example
956
+ * ```typescript
957
+ * const para = paragraph([
958
+ * 'First line of text',
959
+ * 'Second line of text',
960
+ * 'Third line of text'
961
+ * ], { alignment: 'left', fontSize: 14 });
962
+ * ```
406
963
  */
407
-
964
+ declare function paragraph(lines: string[], options?: {
965
+ alignment?: 'left' | 'center' | 'right';
966
+ lineHeight?: number;
967
+ fontSize?: number;
968
+ fontFamily?: string;
969
+ }): Diagram;
408
970
  /**
409
- * 渲染 Diagram 到 SVG 元素
971
+ * 创建项目列表(BulletedList)
972
+ *
973
+ * 创建带有项目符号的列表。
974
+ *
975
+ * @param items - 列表项数组
976
+ * @param options - 可选配置
977
+ * @param options.bulletChar - 项目符号字符,默认 '•'
978
+ * @param options.indent - 缩进距离,默认 20
979
+ * @param options.fontSize - 字体大小
980
+ * @param options.lineHeight - 行高倍数
981
+ * @returns Diagram 对象
982
+ *
983
+ * @example
984
+ * ```typescript
985
+ * const list = bulletedList([
986
+ * 'First item',
987
+ * 'Second item',
988
+ * 'Third item'
989
+ * ]);
990
+ * ```
410
991
  */
411
- declare function renderToSVG(diagram: Diagram, container: SVGSVGElement | HTMLElement, options?: RenderOptions): SVGSVGElement;
992
+ declare function bulletedList(items: string[], options?: {
993
+ bulletChar?: string;
994
+ indent?: number;
995
+ fontSize?: number;
996
+ lineHeight?: number;
997
+ fontFamily?: string;
998
+ }): Diagram;
412
999
  /**
413
- * 将 Diagram 转换为 SVG 字符串
1000
+ * 创建代码块(Code)
1001
+ *
1002
+ * 创建用于显示代码的文本块,使用等宽字体。
1003
+ * 注意:这是一个简化版本,不包含语法高亮。
1004
+ *
1005
+ * @param source - 代码源文本
1006
+ * @param options - 可选配置
1007
+ * @param options.fontSize - 字体大小
1008
+ * @param options.theme - 主题:'dark' 或 'light'
1009
+ * @param options.showLineNumbers - 是否显示行号
1010
+ * @param options.lineNumberWidth - 行号宽度
1011
+ * @returns Diagram 对象
1012
+ *
1013
+ * @example
1014
+ * ```typescript
1015
+ * const codeBlock = code(`
1016
+ * function hello() {
1017
+ * console.log("Hello, World!");
1018
+ * }
1019
+ * `, { theme: 'dark', showLineNumbers: true });
1020
+ * ```
414
1021
  */
415
- declare function toSVGString(diagram: Diagram, options?: RenderOptions): string;
416
-
1022
+ declare function code(source: string, options?: {
1023
+ fontSize?: number;
1024
+ theme?: 'dark' | 'light';
1025
+ showLineNumbers?: boolean;
1026
+ lineNumberWidth?: number;
1027
+ lineHeight?: number;
1028
+ }): Diagram;
417
1029
  /**
418
- * @locusing/core - Rough.js 渲染器
1030
+ * 创建标记文本(MarkupText)
419
1031
  *
420
- * 将 Diagram 渲染为手绘风格的 SVG
1032
+ * 支持基本标记的富文本。支持的标记:
1033
+ * - <b>粗体</b>
1034
+ * - <i>斜体</i>
1035
+ * - <color=red>颜色</color>
1036
+ *
1037
+ * 注意:这是一个简化版本,实际渲染为普通文本。
1038
+ * 完整的标记支持需要更复杂的解析和渲染逻辑。
1039
+ *
1040
+ * @param content - 包含标记的文本内容
1041
+ * @param options - 可选配置
1042
+ * @param options.fontSize - 字体大小
1043
+ * @param options.fontFamily - 字体
1044
+ * @returns Diagram 对象
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * // 注意:标记会被解析但渲染为普通文本
1049
+ * const richText = markupText('Normal and <b>bold</b> text', { fontSize: 16 });
1050
+ * ```
421
1051
  */
422
-
1052
+ declare function markupText(content: string, options?: {
1053
+ fontSize?: number;
1054
+ fontFamily?: string;
1055
+ }): Diagram;
423
1056
  /**
424
- * Rough.js 渲染选项
1057
+ * 创建十字形标记(CrossMark)
1058
+ *
1059
+ * 创建一个 X 或 + 形状的十字标记。
1060
+ * 注意:函数名为 crossMark 以避免与向量叉积运算 cross 冲突。
1061
+ *
1062
+ * @param size - 十字的大小(对角线长度或臂长)
1063
+ * @param options - 可选配置
1064
+ * @param options.strokeWidth - 线条宽度
1065
+ * @param options.style - 样式:'x' 为 X 形,'plus' 为 + 形
1066
+ * @returns Diagram 对象
1067
+ *
1068
+ * @example
1069
+ * ```typescript
1070
+ * // 创建 X 形十字
1071
+ * const x = crossMark(40).stroke('#FC6255').translate(100, 100);
1072
+ *
1073
+ * // 创建 + 形十字
1074
+ * const plus = crossMark(40, { style: 'plus' }).stroke('#58C4DD');
1075
+ * ```
425
1076
  */
426
- interface RoughRenderOptions extends RenderOptions {
427
- roughness?: number;
428
- bowing?: number;
429
- seed?: number;
430
- fillStyle?: 'hachure' | 'solid' | 'zigzag' | 'cross-hatch' | 'dots' | 'dashed' | 'zigzag-line';
431
- fillWeight?: number;
432
- hachureAngle?: number;
1077
+ declare function crossMark(size: number, options?: {
1078
+ strokeWidth?: number;
1079
+ style?: 'x' | 'plus';
1080
+ }): Diagram;
1081
+ /**
1082
+ * 创建正多角星(RegularPolygram)
1083
+ *
1084
+ * 创建正多角星形,通过密度参数控制星形的尖锐程度。
1085
+ * 与 star 不同,regularPolygram 使用顶点跳跃数来定义形状。
1086
+ *
1087
+ * @param numVertices - 顶点数量
1088
+ * @param density - 连接密度(跳跃数),决定星形的形状
1089
+ * @param radius - 外接圆半径
1090
+ * @returns Diagram 对象
1091
+ *
1092
+ * @example
1093
+ * ```typescript
1094
+ * // 五角星(密度 2)
1095
+ * const star5 = regularPolygram(5, 2, 50).fill('#FFFF00');
1096
+ *
1097
+ * // 七角星(密度 3)
1098
+ * const star7 = regularPolygram(7, 3, 50).fill('#FC6255');
1099
+ * ```
1100
+ */
1101
+ declare function regularPolygram(numVertices: number, density: number, radius: number): Diagram;
1102
+ /**
1103
+ * 创建镂空图形(Cutout)
1104
+ *
1105
+ * 从外部图形中挖出内部图形的形状。
1106
+ * 注意:这是一个简化实现,通过组合图形和设置填充规则来模拟镂空效果。
1107
+ * 实际的布尔运算需要更复杂的路径操作。
1108
+ *
1109
+ * @param outer - 外部图形
1110
+ * @param inner - 内部图形(被挖出的部分)
1111
+ * @returns Diagram 对象
1112
+ *
1113
+ * @example
1114
+ * ```typescript
1115
+ * // 在正方形中挖出圆形
1116
+ * const sq = square(100);
1117
+ * const circ = circle(30);
1118
+ * const result = cutout(sq, circ).fill('#58C4DD');
1119
+ * ```
1120
+ */
1121
+ declare function cutout(outer: Diagram, inner: Diagram): Diagram;
1122
+ /** 组合多个图形 */
1123
+ declare function combine(...diagrams: Diagram[]): Diagram;
1124
+ /** 创建空组 */
1125
+ declare function group$1(): Diagram;
1126
+
1127
+ /**
1128
+ * @locusing/core - SVG 渲染器
1129
+ *
1130
+ * 将 Diagram 渲染为 SVG 元素
1131
+ *
1132
+ * 支持两种坐标模式:
1133
+ * 1. 像素模式(默认):原点在左上角,Y 向下
1134
+ * 2. Frame 模式(Manim 风格):原点在中心,Y 向上
1135
+ */
1136
+
1137
+ /**
1138
+ * 渲染 Diagram 到 SVG 元素
1139
+ *
1140
+ * @param diagram - 要渲染的图形
1141
+ * @param container - SVG 元素或 HTML 容器
1142
+ * @param options - 渲染选项
1143
+ * @returns SVG 元素
1144
+ *
1145
+ * @example
1146
+ * ```typescript
1147
+ * // 像素模式(默认)
1148
+ * renderToSVG(diagram, container, { width: 800, height: 600 });
1149
+ *
1150
+ * // Frame 模式(Manim 风格)
1151
+ * renderToSVG(diagram, container, {
1152
+ * width: 800,
1153
+ * height: 600,
1154
+ * frame: true // 使用默认 16:9 frame
1155
+ * });
1156
+ *
1157
+ * // 自定义 Frame
1158
+ * renderToSVG(diagram, container, {
1159
+ * width: 800,
1160
+ * height: 600,
1161
+ * frame: { width: 20, height: 10 }
1162
+ * });
1163
+ * ```
1164
+ */
1165
+ declare function renderToSVG(diagram: Diagram, container: SVGSVGElement | HTMLElement, options?: RenderOptions): SVGSVGElement;
1166
+ /**
1167
+ * 将 Diagram 转换为 SVG 字符串
1168
+ */
1169
+ declare function toSVGString(diagram: Diagram, options?: RenderOptions): string;
1170
+
1171
+ /**
1172
+ * @locusing/core - Rough.js 渲染器
1173
+ *
1174
+ * 将 Diagram 渲染为手绘风格的 SVG
1175
+ */
1176
+
1177
+ /**
1178
+ * Rough.js 渲染选项
1179
+ */
1180
+ interface RoughRenderOptions extends RenderOptions {
1181
+ roughness?: number;
1182
+ bowing?: number;
1183
+ seed?: number;
1184
+ fillStyle?: 'hachure' | 'solid' | 'zigzag' | 'cross-hatch' | 'dots' | 'dashed' | 'zigzag-line';
1185
+ fillWeight?: number;
1186
+ hachureAngle?: number;
433
1187
  hachureGap?: number;
434
1188
  }
435
1189
  /**
@@ -579,6 +1333,279 @@ declare const easingMap: Record<string, string>;
579
1333
  */
580
1334
  declare function getGSAPEasing(easing: string): string;
581
1335
 
1336
+ /**
1337
+ * Camera - 基础相机系统
1338
+ *
1339
+ * 控制 SVG 视口的位置和缩放
1340
+ */
1341
+
1342
+ /**
1343
+ * 相机配置
1344
+ */
1345
+ interface CameraConfig {
1346
+ /** 视口中心位置 */
1347
+ frameCenter?: Vector2;
1348
+ /** 视口宽度 */
1349
+ frameWidth?: number;
1350
+ /** 视口高度 */
1351
+ frameHeight?: number;
1352
+ }
1353
+ /**
1354
+ * 视口帧
1355
+ */
1356
+ interface Frame {
1357
+ x: number;
1358
+ y: number;
1359
+ width: number;
1360
+ height: number;
1361
+ }
1362
+ /**
1363
+ * Camera 类
1364
+ *
1365
+ * 管理 SVG 视口,支持平移和缩放
1366
+ */
1367
+ declare class Camera {
1368
+ protected _center: Vector2;
1369
+ protected _width: number;
1370
+ protected _height: number;
1371
+ /**
1372
+ * 创建相机
1373
+ * @param config - 相机配置
1374
+ */
1375
+ constructor(config?: CameraConfig);
1376
+ /**
1377
+ * 获取视口中心
1378
+ */
1379
+ get center(): Vector2;
1380
+ /**
1381
+ * 设置视口中心
1382
+ */
1383
+ set center(value: Vector2);
1384
+ /**
1385
+ * 获取视口宽度
1386
+ */
1387
+ get width(): number;
1388
+ /**
1389
+ * 设置视口宽度
1390
+ */
1391
+ set width(value: number);
1392
+ /**
1393
+ * 获取视口高度
1394
+ */
1395
+ get height(): number;
1396
+ /**
1397
+ * 设置视口高度
1398
+ */
1399
+ set height(value: number);
1400
+ /**
1401
+ * 获取可视区域
1402
+ */
1403
+ getFrame(): Frame;
1404
+ /**
1405
+ * 移动相机到指定位置
1406
+ * @param point - 目标位置
1407
+ */
1408
+ moveTo(point: Vector2): this;
1409
+ /**
1410
+ * 相对移动相机
1411
+ * @param delta - 移动增量
1412
+ */
1413
+ moveBy(delta: Vector2): this;
1414
+ /**
1415
+ * 缩放视口
1416
+ * @param factor - 缩放因子(>1 缩小视野,<1 放大视野)
1417
+ */
1418
+ zoom(factor: number): this;
1419
+ /**
1420
+ * 设置视口大小
1421
+ * @param width - 宽度
1422
+ * @param height - 高度
1423
+ */
1424
+ setSize(width: number, height: number): this;
1425
+ /**
1426
+ * 重置相机到初始状态
1427
+ */
1428
+ reset(): this;
1429
+ /**
1430
+ * 获取 SVG viewBox 字符串
1431
+ */
1432
+ getViewBox(): string;
1433
+ /**
1434
+ * 应用相机设置到 SVG 元素
1435
+ * @param svg - SVG 元素
1436
+ */
1437
+ applyToSVG(svg: SVGSVGElement): void;
1438
+ /**
1439
+ * 将屏幕坐标转换为世界坐标
1440
+ * @param screenPoint - 屏幕坐标
1441
+ * @param svgWidth - SVG 元素宽度
1442
+ * @param svgHeight - SVG 元素高度
1443
+ */
1444
+ screenToWorld(screenPoint: Vector2, svgWidth: number, svgHeight: number): Vector2;
1445
+ /**
1446
+ * 将世界坐标转换为屏幕坐标
1447
+ * @param worldPoint - 世界坐标
1448
+ * @param svgWidth - SVG 元素宽度
1449
+ * @param svgHeight - SVG 元素高度
1450
+ */
1451
+ worldToScreen(worldPoint: Vector2, svgWidth: number, svgHeight: number): Vector2;
1452
+ /**
1453
+ * 检查点是否在视口内
1454
+ * @param point - 要检查的点
1455
+ */
1456
+ isPointInView(point: Vector2): boolean;
1457
+ /**
1458
+ * 获取当前缩放级别
1459
+ * @param baseWidth - 基准宽度(默认 400)
1460
+ */
1461
+ getZoomLevel(baseWidth?: number): number;
1462
+ /**
1463
+ * 设置缩放级别
1464
+ * @param level - 目标缩放级别
1465
+ * @param baseWidth - 基准宽度(默认 400)
1466
+ */
1467
+ setZoomLevel(level: number, baseWidth?: number): this;
1468
+ /**
1469
+ * 克隆相机
1470
+ */
1471
+ clone(): Camera;
1472
+ }
1473
+ /**
1474
+ * 创建相机
1475
+ * @param config - 相机配置
1476
+ */
1477
+ declare function createCamera(config?: CameraConfig): Camera;
1478
+
1479
+ /**
1480
+ * MovingCamera - 支持动画的相机
1481
+ *
1482
+ * 扩展基础相机,添加平滑移动和动画功能
1483
+ */
1484
+
1485
+ /**
1486
+ * 移动相机配置
1487
+ */
1488
+ interface MovingCameraConfig extends CameraConfig {
1489
+ /** 默认动画时长 */
1490
+ defaultDuration?: number;
1491
+ /** 默认缓动函数 */
1492
+ defaultEasing?: string;
1493
+ }
1494
+ /**
1495
+ * 相机动画选项
1496
+ */
1497
+ interface CameraAnimationOptions$1 {
1498
+ /** 动画时长(秒) */
1499
+ duration?: number;
1500
+ /** 缓动函数名称 */
1501
+ easing?: string;
1502
+ /** 动画完成回调 */
1503
+ onComplete?: () => void;
1504
+ /** 动画更新回调 */
1505
+ onUpdate?: (progress: number) => void;
1506
+ }
1507
+ /**
1508
+ * 相机动画状态
1509
+ */
1510
+ interface CameraAnimationState {
1511
+ /** 是否正在动画 */
1512
+ isAnimating: boolean;
1513
+ /** 起始帧 */
1514
+ startFrame: Frame;
1515
+ /** 目标帧 */
1516
+ endFrame: Frame;
1517
+ /** 开始时间 */
1518
+ startTime: number;
1519
+ /** 动画时长 */
1520
+ duration: number;
1521
+ /** 缓动函数 */
1522
+ easing: (t: number) => number;
1523
+ /** 完成回调 */
1524
+ onComplete?: (() => void) | undefined;
1525
+ /** 更新回调 */
1526
+ onUpdate?: ((progress: number) => void) | undefined;
1527
+ }
1528
+ /**
1529
+ * MovingCamera 类
1530
+ *
1531
+ * 支持平滑动画的相机
1532
+ */
1533
+ declare class MovingCamera extends Camera {
1534
+ protected defaultDuration: number;
1535
+ protected defaultEasing: string;
1536
+ protected animationState: CameraAnimationState | null;
1537
+ protected animationFrameId: number | null;
1538
+ /**
1539
+ * 创建移动相机
1540
+ * @param config - 相机配置
1541
+ */
1542
+ constructor(config?: MovingCameraConfig);
1543
+ /**
1544
+ * 平滑移动到位置
1545
+ * @param point - 目标位置
1546
+ * @param options - 动画选项
1547
+ */
1548
+ animateMoveTo(point: Vector2, options?: CameraAnimationOptions$1): Promise<void>;
1549
+ /**
1550
+ * 平滑缩放
1551
+ * @param factor - 缩放因子
1552
+ * @param options - 动画选项
1553
+ */
1554
+ animateZoom(factor: number, options?: CameraAnimationOptions$1): Promise<void>;
1555
+ /**
1556
+ * 平滑设置缩放级别
1557
+ * @param level - 目标缩放级别
1558
+ * @param options - 动画选项
1559
+ */
1560
+ animateZoomLevel(level: number, options?: CameraAnimationOptions$1): Promise<void>;
1561
+ /**
1562
+ * 平滑移动并缩放到框定指定区域
1563
+ * @param frame - 目标区域
1564
+ * @param options - 动画选项
1565
+ */
1566
+ animateToFrame(frame: Frame, options?: CameraAnimationOptions$1): Promise<void>;
1567
+ /**
1568
+ * 聚焦到图形(根据图形边界框调整视口)
1569
+ * @param target - 目标图形
1570
+ * @param padding - 边距比例(0-1)
1571
+ * @param options - 动画选项
1572
+ */
1573
+ focusOn(target: Diagram, padding?: number, options?: CameraAnimationOptions$1): Promise<void>;
1574
+ /**
1575
+ * 获取图形边界(简化实现)
1576
+ */
1577
+ protected getDiagramBounds(_target: Diagram): Frame;
1578
+ /**
1579
+ * 停止当前动画
1580
+ */
1581
+ stopAnimation(): void;
1582
+ /**
1583
+ * 检查是否正在动画
1584
+ */
1585
+ isAnimating(): boolean;
1586
+ /**
1587
+ * 启动动画
1588
+ */
1589
+ protected startAnimation(startFrame: Frame, endFrame: Frame, duration: number, easingName: string, onComplete?: () => void, onUpdate?: (progress: number) => void): Promise<void>;
1590
+ /**
1591
+ * 动画帧更新
1592
+ */
1593
+ protected animateFrame: () => void;
1594
+ /**
1595
+ * 获取缓动函数
1596
+ */
1597
+ protected getEasingFunction(name: string): (t: number) => number;
1598
+ /**
1599
+ * 克隆移动相机
1600
+ */
1601
+ clone(): MovingCamera;
1602
+ }
1603
+ /**
1604
+ * 创建移动相机
1605
+ * @param config - 相机配置
1606
+ */
1607
+ declare function createMovingCamera(config?: MovingCameraConfig): MovingCamera;
1608
+
582
1609
  /**
583
1610
  * @locusing/animate - Scene 场景管理
584
1611
  *
@@ -591,32 +1618,96 @@ interface SceneConfig {
591
1618
  background?: string;
592
1619
  fps?: number;
593
1620
  rough?: boolean;
1621
+ /** 相机配置 */
1622
+ camera?: CameraConfig;
594
1623
  }
595
1624
  /**
596
1625
  * Scene 类 - Manim 风格的场景管理
597
1626
  *
598
- * 使用方式:
1627
+ * 使用方式一:继承并实现 construct 方法
599
1628
  * ```typescript
600
1629
  * class MyScene extends Scene {
601
1630
  * construct() {
602
- * const sq = square(100).fill('#EA580C');
1631
+ * const sq = square(0.5).fill('#EA580C');
603
1632
  * this.play(Create(sq));
604
1633
  * this.wait(1);
605
1634
  * this.play(FadeOut(sq));
606
1635
  * }
607
1636
  * }
1637
+ * // 在编辑器或文档中使用
1638
+ * play(MyScene);
1639
+ * ```
1640
+ *
1641
+ * 使用方式二:传入容器直接使用
1642
+ * ```typescript
1643
+ * const scene = new MyScene();
1644
+ * scene.setup(svgElement, { width: 800, height: 600 });
1645
+ * scene.construct();
608
1646
  * ```
609
1647
  */
1648
+ /** 内部配置类型(不包含 camera,因为 camera 作为独立实例管理) */
1649
+ interface InternalSceneConfig {
1650
+ width: number;
1651
+ height: number;
1652
+ background: string;
1653
+ fps: number;
1654
+ rough: boolean;
1655
+ }
1656
+ /** Updater 函数类型 */
1657
+ type UpdaterFunction = (diagram: Diagram, dt: number) => void;
1658
+ /** Updater 配置 */
1659
+ interface UpdaterConfig {
1660
+ /** Updater 函数 */
1661
+ fn: UpdaterFunction;
1662
+ /** 关联的图形 */
1663
+ diagram: Diagram;
1664
+ }
610
1665
  declare abstract class Scene {
611
- protected container: HTMLElement;
1666
+ protected container: HTMLElement | SVGSVGElement;
612
1667
  protected svg: SVGSVGElement;
613
- protected config: Required<SceneConfig>;
1668
+ /** Y 轴翻转组,所有内容都渲染到这个组中 */
1669
+ protected flipGroup: SVGGElement;
1670
+ protected config: InternalSceneConfig;
614
1671
  protected timeline: Timeline;
615
1672
  protected objects: Map<string, Diagram>;
616
1673
  protected currentTime: number;
617
- constructor(container: HTMLElement, config?: SceneConfig);
1674
+ protected _isSetup: boolean;
1675
+ /** Frame 逻辑尺寸(用于坐标系统) */
1676
+ protected frameWidth: number;
1677
+ protected frameHeight: number;
1678
+ /** 相机实例 */
1679
+ camera: Camera;
1680
+ /** Updaters 列表 */
1681
+ protected updaters: UpdaterConfig[];
1682
+ /** 上一帧时间(用于计算 dt) */
1683
+ protected lastFrameTime: number;
1684
+ /** 动画帧 ID */
1685
+ protected animationFrameId: number | null;
1686
+ /**
1687
+ * 创建 Scene 实例
1688
+ * @param container - 可选的容器元素。如果不传,需要后续调用 setup() 方法
1689
+ * @param config - 场景配置
1690
+ */
1691
+ constructor(container?: HTMLElement | SVGSVGElement, config?: SceneConfig);
1692
+ /**
1693
+ * 初始化场景(内部方法)
1694
+ */
1695
+ private initScene;
1696
+ /**
1697
+ * 更新相机的 viewBox 到 SVG
1698
+ * 在相机移动或缩放后调用此方法
1699
+ */
1700
+ updateCameraViewBox(): void;
1701
+ /**
1702
+ * 设置场景(延迟初始化)
1703
+ * 用于编辑器和文档中的使用场景,在实例化后调用
1704
+ *
1705
+ * @param svgOrContainer - SVG 元素或容器元素
1706
+ * @param config - 场景配置
1707
+ */
1708
+ setup(svgOrContainer: SVGSVGElement | HTMLElement, config?: SceneConfig): void;
618
1709
  /** 子类实现此方法来构建动画 */
619
- abstract construct(): void;
1710
+ abstract construct(): void | Promise<void>;
620
1711
  /**
621
1712
  * 添加图形到场景(不带动画)
622
1713
  */
@@ -636,12 +1727,60 @@ declare abstract class Scene {
636
1727
  * 等待指定时间
637
1728
  */
638
1729
  wait(seconds?: number): void;
1730
+ /**
1731
+ * 为图形添加 updater
1732
+ *
1733
+ * Updater 会在每一帧被调用,用于创建动态效果
1734
+ *
1735
+ * @param diagram - 要添加 updater 的图形
1736
+ * @param fn - updater 函数,接收图形和时间增量
1737
+ *
1738
+ * @example
1739
+ * ```typescript
1740
+ * const dot = circle(0.1).fill('#EA580C');
1741
+ * this.add(dot);
1742
+ *
1743
+ * // 让 dot 跟随鼠标或按时间变化
1744
+ * this.addUpdater(dot, (d, dt) => {
1745
+ * const t = this.getTime();
1746
+ * return d.move([Math.cos(t), Math.sin(t)]);
1747
+ * });
1748
+ * ```
1749
+ */
1750
+ addUpdater(diagram: Diagram, fn: UpdaterFunction): void;
1751
+ /**
1752
+ * 移除图形的 updater
1753
+ */
1754
+ removeUpdater(diagram: Diagram, fn?: UpdaterFunction): void;
1755
+ /**
1756
+ * 清除所有 updaters
1757
+ */
1758
+ clearUpdaters(): void;
1759
+ /**
1760
+ * 获取当前时间(秒)
1761
+ */
1762
+ getTime(): number;
1763
+ /**
1764
+ * 启动帧循环(用于 updaters)
1765
+ */
1766
+ protected startFrameLoop(): void;
1767
+ /**
1768
+ * 停止帧循环
1769
+ */
1770
+ protected stopFrameLoop(): void;
639
1771
  /**
640
1772
  * 运行场景
641
1773
  */
642
1774
  render(): Promise<void>;
643
1775
  /**
644
- * 渲染单个图形到 SVG
1776
+ * 启动动画播放
1777
+ * 调用此方法开始播放 construct() 中构建的动画
1778
+ *
1779
+ * @returns Promise 在动画完成后 resolve
1780
+ */
1781
+ start(): Promise<void>;
1782
+ /**
1783
+ * 渲染单个图形到 SVG(使用 Frame 模式)
645
1784
  */
646
1785
  protected renderDiagram(diagram: Diagram): SVGElement | null;
647
1786
  /**
@@ -659,7 +1798,7 @@ declare abstract class Scene {
659
1798
  /**
660
1799
  * 获取配置
661
1800
  */
662
- getConfig(): Required<SceneConfig>;
1801
+ getConfig(): InternalSceneConfig;
663
1802
  /**
664
1803
  * 导出为 SVG 字符串
665
1804
  */
@@ -842,6 +1981,61 @@ declare class ValueTracker {
842
1981
  };
843
1982
  }
844
1983
 
1984
+ /**
1985
+ * MovingCameraScene - 支持相机动画的场景
1986
+ *
1987
+ * 扩展基础 Scene,使用 MovingCamera 实现平滑的相机移动和缩放动画
1988
+ */
1989
+
1990
+ interface MovingCameraSceneConfig extends Omit<SceneConfig, 'camera'> {
1991
+ /** 移动相机配置 */
1992
+ camera?: MovingCameraConfig;
1993
+ }
1994
+ /**
1995
+ * MovingCameraScene 类
1996
+ *
1997
+ * 支持相机动画的场景,使用 MovingCamera 替代普通 Camera
1998
+ *
1999
+ * @example
2000
+ * ```typescript
2001
+ * class MyScene extends MovingCameraScene {
2002
+ * construct() {
2003
+ * const sq = square(1).fill(Colors.BLUE);
2004
+ * this.add(sq);
2005
+ *
2006
+ * // 相机缩放动画
2007
+ * this.play(CameraZoom(this.camera, 2));
2008
+ *
2009
+ * // 相机移动到对象
2010
+ * this.play(CameraMove(this.camera, sq.center()));
2011
+ * }
2012
+ * }
2013
+ * ```
2014
+ */
2015
+ declare abstract class MovingCameraScene extends Scene {
2016
+ /** 移动相机实例(覆盖父类的 camera 类型) */
2017
+ camera: MovingCamera;
2018
+ /**
2019
+ * 创建 MovingCameraScene 实例
2020
+ * @param container - 可选的容器元素
2021
+ * @param config - 场景配置
2022
+ */
2023
+ constructor(container?: HTMLElement | SVGSVGElement, config?: MovingCameraSceneConfig);
2024
+ /**
2025
+ * 初始化场景(重写以使用 MovingCamera)
2026
+ */
2027
+ setup(svgOrContainer: SVGSVGElement | HTMLElement, config?: MovingCameraSceneConfig): void;
2028
+ }
2029
+ /**
2030
+ * 创建简单的 MovingCameraScene(不需要继承)
2031
+ */
2032
+ declare function createMovingCameraScene(container: HTMLElement, buildFn: (scene: SimpleMovingCameraScene) => void, config?: MovingCameraSceneConfig): SimpleMovingCameraScene;
2033
+ declare class SimpleMovingCameraScene extends MovingCameraScene {
2034
+ private buildFn;
2035
+ constructor(container: HTMLElement, buildFn: (scene: SimpleMovingCameraScene) => void, config?: MovingCameraSceneConfig);
2036
+ construct(): void;
2037
+ }
2038
+
845
2039
  /**
846
2040
  * 创建类动画 - Create, Write, DrawBorderThenFill
847
2041
  */
@@ -878,6 +2072,24 @@ declare function GrowFromEdge(target: Diagram, edge?: 'LEFT' | 'RIGHT' | 'TOP' |
878
2072
  * SpinInFromNothing - 旋转出现
879
2073
  */
880
2074
  declare function SpinInFromNothing(target: Diagram, options?: CreateOptions): Animation;
2075
+ /**
2076
+ * Uncreate - 逆向创建动画
2077
+ *
2078
+ * Create 的反向效果,让图形从终点向起点擦除
2079
+ */
2080
+ declare function Uncreate(target: Diagram, options?: CreateOptions): Animation;
2081
+ /**
2082
+ * Unwrite - 逆向书写动画
2083
+ *
2084
+ * Write 的反向效果,逐字消失文本
2085
+ */
2086
+ declare function Unwrite(target: Diagram, options?: CreateOptions): Animation;
2087
+ /**
2088
+ * ShrinkToCenter - 收缩到中心消失
2089
+ *
2090
+ * GrowFromCenter 的反向效果,图形收缩到中心点并消失
2091
+ */
2092
+ declare function ShrinkToCenter(target: Diagram, options?: CreateOptions): Animation;
881
2093
 
882
2094
  /**
883
2095
  * 淡入淡出动画 - FadeIn, FadeOut
@@ -954,15 +2166,47 @@ declare function Morphing(source: Diagram, target: Diagram, options?: TransformO
954
2166
  * 智能匹配源和目标中的相似形状进行变换
955
2167
  */
956
2168
  declare function TransformMatchingShapes(source: Diagram, target: Diagram, options?: TransformOptions): Animation;
957
-
958
2169
  /**
959
- * 移动动画 - Shift, MoveTo, MoveAlongPath
2170
+ * TransformMatchingTex 选项
960
2171
  */
961
-
2172
+ interface TransformMatchingTexOptions extends TransformOptions {
2173
+ /** 键映射:将源中的符号映射到目标中的对应符号 */
2174
+ keyMap?: Record<string, string>;
2175
+ }
962
2176
  /**
963
- * Shift - 平移动画
2177
+ * TransformMatchingTex - 匹配 TeX 变换
2178
+ *
2179
+ * 智能匹配 LaTeX 公式中的相同部分进行变换
964
2180
  */
965
- declare function Shift(target: Diagram, offset: Vector2, options?: AnimationConfig): Animation;
2181
+ declare function TransformMatchingTex(source: Diagram, target: Diagram, options?: TransformMatchingTexOptions): Animation;
2182
+ /**
2183
+ * ClockwiseTransform - 顺时针变换
2184
+ *
2185
+ * 图形沿顺时针方向旋转变换到目标状态
2186
+ */
2187
+ declare function ClockwiseTransform(source: Diagram, target: Diagram, options?: TransformOptions): Animation;
2188
+ /**
2189
+ * CounterclockwiseTransform - 逆时针变换
2190
+ *
2191
+ * 图形沿逆时针方向旋转变换到目标状态
2192
+ */
2193
+ declare function CounterclockwiseTransform(source: Diagram, target: Diagram, options?: TransformOptions): Animation;
2194
+ /**
2195
+ * TransformFromCopy - 从副本变换
2196
+ *
2197
+ * 创建源图形的副本,然后将副本变换到目标位置
2198
+ * 源图形保持不变
2199
+ */
2200
+ declare function TransformFromCopy(source: Diagram, target: Diagram, options?: TransformOptions): Animation;
2201
+
2202
+ /**
2203
+ * 移动动画 - Shift, MoveTo, MoveAlongPath
2204
+ */
2205
+
2206
+ /**
2207
+ * Shift - 平移动画
2208
+ */
2209
+ declare function Shift(target: Diagram, offset: Vector2, options?: AnimationConfig): Animation;
966
2210
  /**
967
2211
  * MoveTo - 移动到指定位置
968
2212
  */
@@ -984,16 +2228,35 @@ declare function Rotating(target: Diagram, options?: AnimationConfig & {
984
2228
  angularVelocity?: number;
985
2229
  aboutPoint?: Vector2;
986
2230
  }): Animation;
987
- /**
988
- * Scale - 缩放动画
989
- */
990
- declare function Scale(target: Diagram, factor: number | [number, number], options?: AnimationConfig & {
991
- aboutPoint?: Vector2;
992
- }): Animation;
993
2231
  /**
994
2232
  * ScaleInPlace - 原地缩放
995
2233
  */
996
2234
  declare function ScaleInPlace(target: Diagram, factor: number, options?: AnimationConfig): Animation;
2235
+ /**
2236
+ * Swap 选项
2237
+ */
2238
+ interface SwapOptions extends AnimationConfig {
2239
+ /** 交换路径类型 */
2240
+ path?: 'arc' | 'straight';
2241
+ }
2242
+ /**
2243
+ * CyclicReplace - 循环替换位置
2244
+ *
2245
+ * 多个图形循环交换位置(A→B, B→C, C→A)
2246
+ */
2247
+ declare function CyclicReplace(diagrams: Diagram[], options?: AnimationConfig): Animation;
2248
+ /**
2249
+ * Swap - 交换两个图形位置
2250
+ *
2251
+ * 两个图形互换位置,可选直线或弧线路径
2252
+ */
2253
+ declare function Swap(a: Diagram, b: Diagram, options?: SwapOptions): Animation;
2254
+ /**
2255
+ * FadeToColor - 渐变到目标颜色
2256
+ *
2257
+ * 图形颜色平滑过渡到目标颜色
2258
+ */
2259
+ declare function FadeToColor(target: Diagram, color: string, options?: AnimationConfig): Animation;
997
2260
 
998
2261
  /**
999
2262
  * 指示动画 - Indicate, Circumscribe, Wiggle, Flash
@@ -1033,6 +2296,68 @@ declare function ShowPassingFlash(target: Diagram, options?: IndicateOptions): A
1033
2296
  declare function Blink(target: Diagram, options?: IndicateOptions & {
1034
2297
  times?: number;
1035
2298
  }): Animation;
2299
+ /**
2300
+ * ApplyWave 选项
2301
+ */
2302
+ interface ApplyWaveOptions extends IndicateOptions {
2303
+ /** 波浪方向: 'horizontal' | 'vertical' */
2304
+ direction?: 'horizontal' | 'vertical';
2305
+ /** 波浪幅度 */
2306
+ amplitude?: number;
2307
+ /** 波浪频率 */
2308
+ frequency?: number;
2309
+ }
2310
+ /**
2311
+ * ApplyWave - 波浪效果
2312
+ *
2313
+ * 对图形应用波浪状变形效果
2314
+ */
2315
+ declare function ApplyWave(target: Diagram, options?: ApplyWaveOptions): Animation;
2316
+ /**
2317
+ * FocusOn 选项
2318
+ */
2319
+ interface FocusOnOptions extends IndicateOptions {
2320
+ /** 聚焦缩放比例 */
2321
+ scaleAbout?: number;
2322
+ /** 周围区域暗化程度 */
2323
+ dimSurroundings?: number;
2324
+ }
2325
+ /**
2326
+ * FocusOn - 聚焦效果
2327
+ *
2328
+ * 放大目标图形,同时淡化背景
2329
+ */
2330
+ declare function FocusOn(target: Diagram, options?: FocusOnOptions): Animation;
2331
+ /**
2332
+ * SpiralIn 选项
2333
+ */
2334
+ interface SpiralInOptions extends IndicateOptions {
2335
+ /** 螺旋圈数 */
2336
+ spirals?: number;
2337
+ /** 起始距离 */
2338
+ startDistance?: number;
2339
+ }
2340
+ /**
2341
+ * SpiralIn - 螺旋进入
2342
+ *
2343
+ * 图形从外部螺旋进入到目标位置
2344
+ */
2345
+ declare function SpiralIn(target: Diagram, options?: SpiralInOptions): Animation;
2346
+ /**
2347
+ * PhaseFlow 选项
2348
+ */
2349
+ interface PhaseFlowOptions extends IndicateOptions {
2350
+ /** 相位函数 */
2351
+ phaseFunc?: (x: number, y: number, t: number) => [number, number];
2352
+ /** 流动速度 */
2353
+ flowSpeed?: number;
2354
+ }
2355
+ /**
2356
+ * PhaseFlow - 相位流动
2357
+ *
2358
+ * 基于相位函数的流动效果,常用于向量场可视化
2359
+ */
2360
+ declare function PhaseFlow(target: Diagram, options?: PhaseFlowOptions): Animation;
1036
2361
 
1037
2362
  /**
1038
2363
  * 组合动画 - AnimationGroup, Succession, LaggedStart
@@ -1091,6 +2416,131 @@ declare function UpdateFromAlphaFunc(target: Diagram, updateFn: (diagram: Diagra
1091
2416
  */
1092
2417
  declare function Homotopy(target: Diagram, homotopyFn: (x: number, y: number, t: number) => [number, number], options?: AnimationConfig): Animation;
1093
2418
 
2419
+ /**
2420
+ * 文本动画 - AddTextLetterByLetter, RemoveTextLetterByLetter, Typewriter
2421
+ *
2422
+ * Phase 2 Batch 2: 文本相关的动画效果
2423
+ */
2424
+
2425
+ /**
2426
+ * 文本动画选项
2427
+ */
2428
+ interface TextAnimationOptions extends AnimationConfig {
2429
+ /** 每个字符的显示时间 */
2430
+ timePerChar?: number;
2431
+ }
2432
+ /**
2433
+ * 打字机动画选项
2434
+ */
2435
+ interface TypewriterOptions extends TextAnimationOptions {
2436
+ /** 是否显示光标 */
2437
+ cursor?: boolean;
2438
+ /** 光标字符 */
2439
+ cursorChar?: string;
2440
+ /** 光标闪烁间隔(秒) */
2441
+ cursorBlinkInterval?: number;
2442
+ }
2443
+ /**
2444
+ * AddTextLetterByLetter - 逐字显示文本
2445
+ *
2446
+ * 从第一个字符开始,逐个显示文本内容
2447
+ */
2448
+ declare function AddTextLetterByLetter(target: Diagram, options?: TextAnimationOptions): Animation;
2449
+ /**
2450
+ * RemoveTextLetterByLetter - 逐字移除文本
2451
+ *
2452
+ * 从最后一个字符开始,逐个隐藏文本内容
2453
+ */
2454
+ declare function RemoveTextLetterByLetter(target: Diagram, options?: TextAnimationOptions): Animation;
2455
+ /**
2456
+ * Typewriter - 打字机效果
2457
+ *
2458
+ * 模拟打字机逐字输入的效果,可选显示闪烁光标
2459
+ */
2460
+ declare function Typewriter(target: Diagram, options?: TypewriterOptions): Animation;
2461
+
2462
+ /**
2463
+ * Camera Animations - 相机动画效果
2464
+ *
2465
+ * 提供相机缩放、移动等动画效果
2466
+ */
2467
+
2468
+ interface CameraAnimationOptions {
2469
+ /** 动画时长(秒) */
2470
+ duration?: number;
2471
+ }
2472
+ /**
2473
+ * 相机缩放动画
2474
+ *
2475
+ * @param camera - 相机实例
2476
+ * @param factor - 缩放因子(>1 视野变大/缩小,<1 视野变小/放大)
2477
+ * @param options - 动画选项
2478
+ *
2479
+ * @example
2480
+ * ```typescript
2481
+ * // 视野扩大 2 倍(缩小显示)
2482
+ * this.play(CameraZoom(this.camera, 2));
2483
+ *
2484
+ * // 视野缩小到一半(放大显示)
2485
+ * this.play(CameraZoom(this.camera, 0.5));
2486
+ * ```
2487
+ */
2488
+ declare function CameraZoom(camera: Camera, factor: number, options?: CameraAnimationOptions): Animation;
2489
+ /**
2490
+ * 相机移动动画
2491
+ *
2492
+ * @param camera - 相机实例
2493
+ * @param target - 目标位置(点坐标或 Diagram)
2494
+ * @param options - 动画选项
2495
+ *
2496
+ * @example
2497
+ * ```typescript
2498
+ * // 移动到指定坐标
2499
+ * this.play(CameraMove(this.camera, [3, 2]));
2500
+ *
2501
+ * // 移动到图形的中心
2502
+ * this.play(CameraMove(this.camera, mySquare));
2503
+ * ```
2504
+ */
2505
+ declare function CameraMove(camera: Camera, targetPosition: Vector2 | Diagram, options?: CameraAnimationOptions): Animation;
2506
+ /**
2507
+ * 相机自动缩放动画
2508
+ *
2509
+ * 自动调整相机视野以包含所有指定的对象
2510
+ *
2511
+ * @param camera - 相机实例
2512
+ * @param targets - 要包含的对象列表
2513
+ * @param options - 动画选项
2514
+ *
2515
+ * @example
2516
+ * ```typescript
2517
+ * // 自动缩放以包含所有对象
2518
+ * this.play(CameraAutoZoom(this.camera, [square, circle], { margin: 0.5 }));
2519
+ * ```
2520
+ */
2521
+ declare function CameraAutoZoom(camera: Camera, targets: Diagram[], options?: CameraAnimationOptions & {
2522
+ margin?: number;
2523
+ }): Animation;
2524
+ /**
2525
+ * 相机重置动画
2526
+ *
2527
+ * 将相机恢复到默认状态(原点居中,16x9 视野)
2528
+ *
2529
+ * @param camera - 相机实例
2530
+ * @param options - 动画选项
2531
+ */
2532
+ declare function CameraReset(camera: Camera, options?: CameraAnimationOptions): Animation;
2533
+ /**
2534
+ * 相机帧动画
2535
+ *
2536
+ * 直接设置相机的视口帧
2537
+ *
2538
+ * @param camera - 相机实例
2539
+ * @param targetFrame - 目标帧
2540
+ * @param options - 动画选项
2541
+ */
2542
+ declare function CameraSetFrame(camera: Camera, targetFrame: Frame, options?: CameraAnimationOptions): Animation;
2543
+
1094
2544
  /**
1095
2545
  * @locusing/geometry - 坐标系
1096
2546
  *
@@ -1109,6 +2559,9 @@ interface AxesConfig {
1109
2559
  axisColor?: string;
1110
2560
  gridColor?: string;
1111
2561
  labelSize?: number;
2562
+ tickSize?: number;
2563
+ strokeWidth?: number;
2564
+ headSize?: number;
1112
2565
  }
1113
2566
  /**
1114
2567
  * Axes - 二维坐标系
@@ -1167,6 +2620,10 @@ declare class NumberLine {
1167
2620
  showTicks?: boolean;
1168
2621
  showLabels?: boolean;
1169
2622
  color?: string;
2623
+ tickSize?: number;
2624
+ strokeWidth?: number;
2625
+ labelSize?: number;
2626
+ headSize?: number;
1170
2627
  });
1171
2628
  private build;
1172
2629
  n2p(n: number): Vector2;
@@ -1185,6 +2642,8 @@ declare function PolarAxes(config?: {
1185
2642
  origin?: Vector2;
1186
2643
  divisions?: number;
1187
2644
  color?: string;
2645
+ strokeWidth?: number;
2646
+ headSize?: number;
1188
2647
  }): Diagram;
1189
2648
 
1190
2649
  /**
@@ -1212,15 +2671,17 @@ declare function parallelLine(point: Vector2, lineStart: Vector2, lineEnd: Vecto
1212
2671
  /**
1213
2672
  * 角度标记
1214
2673
  */
1215
- declare function angleMarker(vertex: Vector2, a: Vector2, b: Vector2, options?: {
2674
+ declare function angleMarker(p1: Vector2, vertex: Vector2, p2: Vector2, options?: {
1216
2675
  radius?: number;
1217
2676
  color?: string;
1218
2677
  label?: string;
2678
+ labelSize?: number;
2679
+ strokeWidth?: number;
1219
2680
  }): Diagram;
1220
2681
  /**
1221
2682
  * 直角标记
1222
2683
  */
1223
- declare function rightAngleMarker(vertex: Vector2, a: Vector2, b: Vector2, size?: number): Diagram;
2684
+ declare function rightAngleMarker(p1: Vector2, vertex: Vector2, p2: Vector2, size?: number, strokeWidth?: number): Diagram;
1224
2685
  /**
1225
2686
  * 过三点的圆
1226
2687
  */
@@ -1252,7 +2713,7 @@ declare function orthocenter(a: Vector2, b: Vector2, c: Vector2): Vector2;
1252
2713
  /**
1253
2714
  * 中线
1254
2715
  */
1255
- declare function median(vertex: Vector2, opposite1: Vector2, opposite2: Vector2): Diagram;
2716
+ declare function median$1(vertex: Vector2, opposite1: Vector2, opposite2: Vector2): Diagram;
1256
2717
  /**
1257
2718
  * 角平分线
1258
2719
  */
@@ -1408,4 +2869,2994 @@ declare function polarConstraint(cx: number, cy: number, minRadius: number, maxR
1408
2869
  */
1409
2870
  declare function functionConstraint(fn: (x: number) => number, minX: number, maxX: number): (p: Vector2) => Vector2;
1410
2871
 
1411
- export { type Animation, type AnimationConfig, AnimationGroup, type AnimationGroupOptions, type AnimationOptions, type AnimationStatus, ApplyMethod, type ArcShape, Axes, type AxesConfig, type BaseShape, Blink, type ButtonConfig, type CircleShape, Circumscribe, type CircumscribeOptions, Create, type CreateOptions, DEGREES, DL, DOWN, DR, Diagram, DrawBorderThenFill, type EasingFunction, type EllipseShape, FadeIn, FadeInFrom, FadeInFromDown, FadeInFromLeft, FadeInFromRight, FadeInFromUp, type FadeOptions, FadeOut, FadeOutTo, FadeTransform, Flash, type FlashOptions, type GroupShape, GrowFromCenter, GrowFromEdge, GrowFromPoint, Homotopy, IDENTITY, Indicate, type IndicateOptions, Interactive, type InteractiveOptions, LEFT, LaggedStart, LaggedStartMap, type LineShape, type LocatorConfig, type LocatorOptions, type Matrix3, Morphing, MoveAlongPath, type MoveOptions, MoveTo, MoveToTarget, NumberLine, NumberPlane, ORIGIN, PI, type PathCommand, type PathShape, type Point, PolarAxes, type PolygonShape, type PolylineShape, RIGHT, type RectShape, type RenderOptions, ReplacementTransform, Rotate, type RotateOptions, Rotating, type RoughRenderOptions, Scale, ScaleInPlace, type ScaleOptions, Scene, type SceneConfig, type Shape, type ShapeType, Shift, ShowPassingFlash, type SliderConfig, type SliderOptions, SpinInFromNothing, type Style, Succession, TAU, type TextShape, type TextStyle, Timeline, type TimelineOptions, Transform, TransformMatchingShapes, type TransformOptions, UL, UP, UR, UpdateFromAlphaFunc, UpdateFromFunc, V2, V3, ValueTracker, type Vector2, type Vector3, Wait, Wiggle, type WiggleOptions, Write, add, altitude, angle, angleBetween, angleBisector, angleMarker, applyMatrix, arc, arrow, centroid, circle, circleConstraint, circleIntersections, circumscribedCircle, clamp, combine, createInteractive, createScene, createTimeline, cross, cubicBezier, degToRad, distance, div, dot, doubleArrow, easing, easingMap, ellipse, equilateralTriangle, footOfPerpendicular, functionConstraint, getGSAPEasing, gridConstraint, group, inscribedCircle, length, lerp, lerpNumber, line, lineConstraint, lineIntersection, mapRange, matrixMultiply, median, midpoint, mul, normalize, orthocenter, parallelLine, path, pathFromString, perpendicular, perpendicularBisector, perpendicularLine, polarConstraint, polygon, polyline, quadraticBezier, radToDeg, rect, rectConstraint, reflect, reflectOverPoint, reflectPoint, reflectPointOverLine, regularPolygon, renderToRough, renderToSVG, rightAngleMarker, rotate, rotationMatrix, roughPresets, sampleParametric, scaleMatrix, sector, square, star, sub, tex, text, toSVGString, translationMatrix, triangle, dot$1 as vectorDot };
2872
+ /**
2873
+ * ManimColor - 颜色处理类
2874
+ *
2875
+ * 提供颜色转换、操作和插值功能
2876
+ */
2877
+ /**
2878
+ * RGB 颜色值
2879
+ */
2880
+ type RGB = [number, number, number];
2881
+ /**
2882
+ * HSL 颜色值
2883
+ */
2884
+ type HSL = [number, number, number];
2885
+ /**
2886
+ * ManimColor 类
2887
+ *
2888
+ * 支持多种格式的颜色输入和操作
2889
+ */
2890
+ declare class ManimColor {
2891
+ private r;
2892
+ private g;
2893
+ private b;
2894
+ /**
2895
+ * 创建颜色
2896
+ * @param value - 颜色值,支持 hex 字符串、RGB 数组或数字
2897
+ */
2898
+ constructor(value: string | number | RGB);
2899
+ /**
2900
+ * 转换为 Hex 格式
2901
+ */
2902
+ toHex(): string;
2903
+ /**
2904
+ * 转换为 RGB 数组
2905
+ */
2906
+ toRGB(): RGB;
2907
+ /**
2908
+ * 转换为 HSL 数组
2909
+ */
2910
+ toHSL(): HSL;
2911
+ /**
2912
+ * 转换为 CSS rgb() 格式
2913
+ */
2914
+ toRGBString(): string;
2915
+ /**
2916
+ * 提亮颜色
2917
+ * @param amount - 提亮程度 (0-1)
2918
+ */
2919
+ lighten(amount: number): ManimColor;
2920
+ /**
2921
+ * 加深颜色
2922
+ * @param amount - 加深程度 (0-1)
2923
+ */
2924
+ darken(amount: number): ManimColor;
2925
+ /**
2926
+ * 增加饱和度
2927
+ * @param amount - 增加程度 (0-1)
2928
+ */
2929
+ saturate(amount: number): ManimColor;
2930
+ /**
2931
+ * 降低饱和度
2932
+ * @param amount - 降低程度 (0-1)
2933
+ */
2934
+ desaturate(amount: number): ManimColor;
2935
+ /**
2936
+ * 颜色插值
2937
+ * @param other - 目标颜色
2938
+ * @param t - 插值系数 (0-1)
2939
+ */
2940
+ interpolate(other: ManimColor, t: number): ManimColor;
2941
+ /**
2942
+ * 混合颜色
2943
+ * @param other - 另一个颜色
2944
+ * @param weight - 混合权重 (0-1),0 表示完全使用当前颜色
2945
+ */
2946
+ mix(other: ManimColor, weight?: number): ManimColor;
2947
+ /**
2948
+ * 获取补色
2949
+ */
2950
+ complement(): ManimColor;
2951
+ /**
2952
+ * 调整透明度(返回 rgba 字符串)
2953
+ * @param alpha - 透明度 (0-1)
2954
+ */
2955
+ withAlpha(alpha: number): string;
2956
+ /**
2957
+ * 从 HSL 创建颜色
2958
+ */
2959
+ static fromHSL(h: number, s: number, l: number): ManimColor;
2960
+ /**
2961
+ * 创建随机颜色
2962
+ */
2963
+ static random(): ManimColor;
2964
+ /**
2965
+ * 创建渐变色数组
2966
+ * @param color1 - 起始颜色
2967
+ * @param color2 - 结束颜色
2968
+ * @param steps - 步数
2969
+ */
2970
+ static gradient(color1: ManimColor, color2: ManimColor, steps: number): ManimColor[];
2971
+ }
2972
+ /**
2973
+ * 颜色插值函数(工具函数)
2974
+ * @param color1 - 起始颜色 (hex)
2975
+ * @param color2 - 结束颜色 (hex)
2976
+ * @param t - 插值系数 (0-1)
2977
+ */
2978
+ declare function interpolateColor(color1: string, color2: string, t: number): string;
2979
+ /**
2980
+ * 颜色渐变函数(工具函数)
2981
+ * @param colors - 颜色数组
2982
+ * @param t - 插值系数 (0-1)
2983
+ */
2984
+ declare function colorGradient(colors: string[], t: number): string;
2985
+
2986
+ /**
2987
+ * Manim 预定义颜色常量
2988
+ *
2989
+ * 包含 Manim 标准颜色和扩展颜色
2990
+ */
2991
+ /**
2992
+ * Manim 标准颜色集
2993
+ */
2994
+ declare const Colors: {
2995
+ readonly WHITE: "#FFFFFF";
2996
+ readonly BLACK: "#000000";
2997
+ readonly GRAY_A: "#F1F5F9";
2998
+ readonly GRAY_B: "#CBD5E1";
2999
+ readonly GRAY_C: "#94A3B8";
3000
+ readonly GRAY_D: "#64748B";
3001
+ readonly GRAY_E: "#334155";
3002
+ readonly GREY_A: "#F1F5F9";
3003
+ readonly GREY_B: "#CBD5E1";
3004
+ readonly GREY_C: "#94A3B8";
3005
+ readonly GREY_D: "#64748B";
3006
+ readonly GREY_E: "#334155";
3007
+ readonly LIGHT_GRAY: "#CBD5E1";
3008
+ readonly LIGHT_GREY: "#CBD5E1";
3009
+ readonly DARK_GRAY: "#64748B";
3010
+ readonly DARK_GREY: "#64748B";
3011
+ readonly BLUE: "#38BDF8";
3012
+ readonly BLUE_A: "#E0F2FE";
3013
+ readonly BLUE_B: "#BAE6FD";
3014
+ readonly BLUE_C: "#38BDF8";
3015
+ readonly BLUE_D: "#0284C7";
3016
+ readonly BLUE_E: "#0C4A6E";
3017
+ readonly PURE_BLUE: "#3B82F6";
3018
+ readonly DARK_BLUE: "#1E40AF";
3019
+ readonly TEAL: "#2DD4BF";
3020
+ readonly TEAL_A: "#CCFBF1";
3021
+ readonly TEAL_B: "#99F6E4";
3022
+ readonly TEAL_C: "#2DD4BF";
3023
+ readonly TEAL_D: "#0F766E";
3024
+ readonly TEAL_E: "#134E4A";
3025
+ readonly GREEN: "#4ADE80";
3026
+ readonly GREEN_A: "#DCFCE7";
3027
+ readonly GREEN_B: "#86EFAC";
3028
+ readonly GREEN_C: "#4ADE80";
3029
+ readonly GREEN_D: "#16A34A";
3030
+ readonly GREEN_E: "#14532D";
3031
+ readonly PURE_GREEN: "#22C55E";
3032
+ readonly YELLOW: "#FACC15";
3033
+ readonly YELLOW_A: "#FEF9C3";
3034
+ readonly YELLOW_B: "#FEF08A";
3035
+ readonly YELLOW_C: "#FACC15";
3036
+ readonly YELLOW_D: "#CA8A04";
3037
+ readonly YELLOW_E: "#713F12";
3038
+ readonly GOLD: "#FBBF24";
3039
+ readonly GOLD_A: "#FDE68A";
3040
+ readonly GOLD_B: "#FCD34D";
3041
+ readonly GOLD_C: "#FBBF24";
3042
+ readonly GOLD_D: "#B45309";
3043
+ readonly GOLD_E: "#78350F";
3044
+ readonly RED: "#FB7185";
3045
+ readonly RED_A: "#FFE4E6";
3046
+ readonly RED_B: "#FECDD3";
3047
+ readonly RED_C: "#FB7185";
3048
+ readonly RED_D: "#E11D48";
3049
+ readonly RED_E: "#881337";
3050
+ readonly PURE_RED: "#F43F5E";
3051
+ readonly MAROON: "#C084FC";
3052
+ readonly MAROON_A: "#E9D5FF";
3053
+ readonly MAROON_B: "#D8B4FE";
3054
+ readonly MAROON_C: "#C084FC";
3055
+ readonly MAROON_D: "#9333EA";
3056
+ readonly MAROON_E: "#581C87";
3057
+ readonly PURPLE: "#A78BFA";
3058
+ readonly PURPLE_A: "#EDE9FE";
3059
+ readonly PURPLE_B: "#DDD6FE";
3060
+ readonly PURPLE_C: "#A78BFA";
3061
+ readonly PURPLE_D: "#7C3AED";
3062
+ readonly PURPLE_E: "#4C1D95";
3063
+ readonly PINK: "#E879F9";
3064
+ readonly PINK_A: "#FAE8FF";
3065
+ readonly PINK_B: "#F0ABFC";
3066
+ readonly PINK_C: "#E879F9";
3067
+ readonly PINK_D: "#C026D3";
3068
+ readonly PINK_E: "#701A75";
3069
+ readonly LIGHT_PINK: "#F5D0FE";
3070
+ readonly ORANGE: "#FB923C";
3071
+ readonly ORANGE_A: "#FFEDD5";
3072
+ readonly ORANGE_B: "#FDBA74";
3073
+ readonly ORANGE_C: "#FB923C";
3074
+ readonly ORANGE_D: "#EA580C";
3075
+ readonly ORANGE_E: "#7C2D12";
3076
+ readonly LIGHT_BROWN: "#D6D3D1";
3077
+ readonly DARK_BROWN: "#57534E";
3078
+ /** 用于坐标轴 - 使用低饱和度的颜色避免抢眼 */
3079
+ readonly X_COLOR: "#94A3B8";
3080
+ /** 用于坐标轴 */
3081
+ readonly Y_COLOR: "#94A3B8";
3082
+ /** 用于坐标轴 */
3083
+ readonly Z_COLOR: "#94A3B8";
3084
+ /** 文本默认颜色 */
3085
+ readonly TEXT_COLOR: "#F8FAFC";
3086
+ /** 背景默认颜色 - 深空灰蓝 */
3087
+ readonly BACKGROUND_COLOR: "#0F172A";
3088
+ /** Manim 默认背景色兼容 */
3089
+ readonly MANIM_BACKGROUND: "#0F172A";
3090
+ };
3091
+ /**
3092
+ * 颜色类型
3093
+ */
3094
+ type ColorName = keyof typeof Colors;
3095
+ /**
3096
+ * 根据名称获取颜色
3097
+ */
3098
+ declare function getColor(name: ColorName): string;
3099
+ /**
3100
+ * 颜色色阶(用于渐变和可视化)
3101
+ */
3102
+ declare const ColorScales: {
3103
+ /** 蓝-红渐变 */
3104
+ readonly BLUE_TO_RED: readonly ["#38BDF8", "#2DD4BF", "#4ADE80", "#FACC15", "#FB923C", "#FB7185"];
3105
+ /** 冷色调 */
3106
+ readonly COOL: readonly ["#0C4A6E", "#38BDF8", "#2DD4BF", "#4ADE80"];
3107
+ /** 暖色调 */
3108
+ readonly WARM: readonly ["#FACC15", "#FB923C", "#FB7185", "#C084FC"];
3109
+ /** 彩虹 */
3110
+ readonly RAINBOW: readonly ["#FB7185", "#FB923C", "#FACC15", "#4ADE80", "#38BDF8", "#A78BFA"];
3111
+ /** 灰度 */
3112
+ readonly GRAYSCALE: readonly ["#FFFFFF", "#F1F5F9", "#CBD5E1", "#94A3B8", "#64748B", "#334155", "#000000"];
3113
+ /** 蓝色色阶 */
3114
+ readonly BLUES: readonly ["#E0F2FE", "#BAE6FD", "#38BDF8", "#0284C7", "#0C4A6E"];
3115
+ /** 红色色阶 */
3116
+ readonly REDS: readonly ["#FFE4E6", "#FECDD3", "#FB7185", "#E11D48", "#881337"];
3117
+ /** 绿色色阶 */
3118
+ readonly GREENS: readonly ["#DCFCE7", "#86EFAC", "#4ADE80", "#16A34A", "#14532D"];
3119
+ };
3120
+ /**
3121
+ * 3B1B 风格颜色(3Blue1Brown 视频常用)
3122
+ */
3123
+ declare const ThreeB1BColors: {
3124
+ /** 3B1B 蓝色 */
3125
+ readonly BLUE: "#58C4DD";
3126
+ /** 3B1B 棕色 */
3127
+ readonly BROWN: "#CD853F";
3128
+ /** 3B1B 金色 */
3129
+ readonly GOLD: "#FFD700";
3130
+ /** 3B1B 绿色 */
3131
+ readonly GREEN: "#83C167";
3132
+ /** 3B1B 红色 */
3133
+ readonly RED: "#FC6255";
3134
+ /** 3B1B 紫色 */
3135
+ readonly PURPLE: "#9A72AC";
3136
+ /** 3B1B 黄色 */
3137
+ readonly YELLOW: "#FFFF00";
3138
+ /** 3B1B 背景色 */
3139
+ readonly BACKGROUND: "#1a1a2e";
3140
+ };
3141
+
3142
+ /**
3143
+ * @locusing/theme - 主题系统类型定义
3144
+ *
3145
+ * 定义 Design Tokens 作为统一风格的唯一事实来源
3146
+ * 参考: plan/09-integration-principles-unified-rendering.md
3147
+ */
3148
+
3149
+ /** 语义颜色 tokens */
3150
+ interface SemanticColors {
3151
+ /** 主色调 */
3152
+ primary: string;
3153
+ /** 次要色调 */
3154
+ secondary: string;
3155
+ /** 强调色 */
3156
+ accent: string;
3157
+ /** 成功色 */
3158
+ success: string;
3159
+ /** 警告色 */
3160
+ warning: string;
3161
+ /** 错误色 */
3162
+ error: string;
3163
+ /** 信息色 */
3164
+ info: string;
3165
+ }
3166
+ /** 背景颜色 tokens */
3167
+ interface BackgroundColors {
3168
+ /** 主背景 */
3169
+ default: string;
3170
+ /** 表面背景(卡片、面板等) */
3171
+ surface: string;
3172
+ /** 悬浮层背景 */
3173
+ overlay: string;
3174
+ }
3175
+ /** 文本颜色 tokens */
3176
+ interface TextColors {
3177
+ /** 默认文本 */
3178
+ default: string;
3179
+ /** 次要文本 */
3180
+ muted: string;
3181
+ /** 反色文本 */
3182
+ inverse: string;
3183
+ }
3184
+ /** 坐标轴颜色 tokens */
3185
+ interface AxisColors {
3186
+ /** X 轴颜色 */
3187
+ x: string;
3188
+ /** Y 轴颜色 */
3189
+ y: string;
3190
+ /** Z 轴颜色(3D) */
3191
+ z: string;
3192
+ }
3193
+ /** 颜色 tokens 集合 */
3194
+ interface ColorTokens {
3195
+ /** 语义颜色 */
3196
+ semantic: SemanticColors;
3197
+ /** 背景颜色 */
3198
+ background: BackgroundColors;
3199
+ /** 文本颜色 */
3200
+ text: TextColors;
3201
+ /** 坐标轴颜色 */
3202
+ axis: AxisColors;
3203
+ /** 扩展调色板(可自定义) */
3204
+ palette: Record<string, string>;
3205
+ }
3206
+ /** 线宽 tokens */
3207
+ interface StrokeWidthTokens {
3208
+ /** 细线 (1px) */
3209
+ thin: number;
3210
+ /** 默认线宽 (2px) */
3211
+ default: number;
3212
+ /** 粗线 (3px) */
3213
+ thick: number;
3214
+ /** 加粗线 (4px) */
3215
+ bold: number;
3216
+ /** 超粗线 (6px) */
3217
+ heavy: number;
3218
+ }
3219
+ /** 虚线模式 tokens */
3220
+ interface DashPatterns {
3221
+ /** 点线 */
3222
+ dotted: string;
3223
+ /** 短虚线 */
3224
+ dashed: string;
3225
+ /** 长虚线 */
3226
+ longDash: string;
3227
+ /** 点划线 */
3228
+ dashDot: string;
3229
+ }
3230
+ /** 描边 tokens 集合 */
3231
+ interface StrokeTokens {
3232
+ /** 线宽 */
3233
+ width: StrokeWidthTokens;
3234
+ /** 线端样式 */
3235
+ linecap: 'butt' | 'round' | 'square';
3236
+ /** 拐角样式 */
3237
+ linejoin: 'miter' | 'round' | 'bevel';
3238
+ /** 虚线模式 */
3239
+ dash: DashPatterns;
3240
+ }
3241
+ /** 字体族 tokens */
3242
+ interface FontFamilyTokens {
3243
+ /** 默认字体 */
3244
+ default: string;
3245
+ /** 等宽字体 */
3246
+ mono: string;
3247
+ /** 数学字体(LaTeX 渲染用) */
3248
+ math: string;
3249
+ }
3250
+ /** 字号 tokens */
3251
+ interface FontSizeTokens {
3252
+ /** 超小 (10px) */
3253
+ xs: number;
3254
+ /** 小 (12px) */
3255
+ sm: number;
3256
+ /** 中等 (14px) */
3257
+ md: number;
3258
+ /** 大 (16px) */
3259
+ lg: number;
3260
+ /** 超大 (20px) */
3261
+ xl: number;
3262
+ /** 标题 (24px) */
3263
+ '2xl': number;
3264
+ }
3265
+ /** 字重 tokens */
3266
+ interface FontWeightTokens {
3267
+ /** 正常 */
3268
+ normal: number;
3269
+ /** 中等 */
3270
+ medium: number;
3271
+ /** 粗体 */
3272
+ bold: number;
3273
+ }
3274
+ /** 排版 tokens 集合 */
3275
+ interface TypographyTokens {
3276
+ /** 字体族 */
3277
+ fontFamily: FontFamilyTokens;
3278
+ /** 字号 */
3279
+ fontSize: FontSizeTokens;
3280
+ /** 字重 */
3281
+ fontWeight: FontWeightTokens;
3282
+ }
3283
+ /** 间距 tokens */
3284
+ interface SpacingTokens {
3285
+ /** 无间距 */
3286
+ none: number;
3287
+ /** 超小间距 (2px) */
3288
+ xs: number;
3289
+ /** 小间距 (4px) */
3290
+ sm: number;
3291
+ /** 中等间距 (8px) */
3292
+ md: number;
3293
+ /** 大间距 (16px) */
3294
+ lg: number;
3295
+ /** 超大间距 (24px) */
3296
+ xl: number;
3297
+ /** 特大间距 (32px) */
3298
+ '2xl': number;
3299
+ }
3300
+ /** 布局 tokens 集合 */
3301
+ interface LayoutTokens {
3302
+ /** 间距 */
3303
+ spacing: SpacingTokens;
3304
+ /** 网格大小(Frame 模式下的逻辑单位) */
3305
+ gridSize: number;
3306
+ /** 默认 buffer 距离(nextTo 等方法使用) */
3307
+ buffer: number;
3308
+ }
3309
+ /** 动画时长 tokens */
3310
+ interface DurationTokens {
3311
+ /** 快速 (0.15s) */
3312
+ fast: number;
3313
+ /** 默认 (0.3s) */
3314
+ default: number;
3315
+ /** 中等 (0.5s) */
3316
+ medium: number;
3317
+ /** 慢速 (1s) */
3318
+ slow: number;
3319
+ /** 非常慢 (2s) */
3320
+ verySlow: number;
3321
+ }
3322
+ /** 缓动函数 tokens */
3323
+ interface EasingTokens {
3324
+ /** 线性 */
3325
+ linear: string;
3326
+ /** 缓入 */
3327
+ easeIn: string;
3328
+ /** 缓出 */
3329
+ easeOut: string;
3330
+ /** 缓入缓出 */
3331
+ easeInOut: string;
3332
+ /** 弹性 */
3333
+ elastic: string;
3334
+ /** 反弹 */
3335
+ bounce: string;
3336
+ /** 平滑(Manim 默认) */
3337
+ smooth: string;
3338
+ }
3339
+ /** 动画 tokens 集合 */
3340
+ interface AnimationTokens {
3341
+ /** 动画时长 */
3342
+ duration: DurationTokens;
3343
+ /** 缓动函数 */
3344
+ easing: EasingTokens;
3345
+ /** 默认错开延迟(stagger) */
3346
+ staggerDelay: number;
3347
+ }
3348
+ /** 主题 tokens 集合(所有 Design Tokens) */
3349
+ interface ThemeTokens {
3350
+ /** 颜色 tokens */
3351
+ color: ColorTokens;
3352
+ /** 描边 tokens */
3353
+ stroke: StrokeTokens;
3354
+ /** 排版 tokens */
3355
+ typography: TypographyTokens;
3356
+ /** 布局 tokens */
3357
+ layout: LayoutTokens;
3358
+ /** 动画 tokens */
3359
+ animation: AnimationTokens;
3360
+ }
3361
+ /** 预计算的样式快捷方式 */
3362
+ interface ThemeStyles {
3363
+ /** 默认描边样式(线条、路径等) */
3364
+ defaultStroke: Style;
3365
+ /** 默认填充样式(形状等) */
3366
+ defaultFill: Style;
3367
+ /** 默认文本样式 */
3368
+ defaultText: TextStyle;
3369
+ /** 坐标轴样式 */
3370
+ axis: Style;
3371
+ /** 网格线样式 */
3372
+ grid: Style;
3373
+ }
3374
+ /** 完整的主题定义 */
3375
+ interface Theme {
3376
+ /** 主题名称 */
3377
+ name: string;
3378
+ /** Design Tokens */
3379
+ tokens: ThemeTokens;
3380
+ /** 预计算的样式 */
3381
+ styles: ThemeStyles;
3382
+ }
3383
+ /** 深度 Partial 类型(用于主题覆盖) */
3384
+ type DeepPartial<T> = {
3385
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
3386
+ };
3387
+ /** 主题覆盖选项 */
3388
+ type ThemeOverrides = DeepPartial<ThemeTokens>;
3389
+
3390
+ /**
3391
+ * @locusing/theme - 预定义主题
3392
+ *
3393
+ * 提供默认主题和 Manim 风格主题
3394
+ */
3395
+
3396
+ /** 默认主题 tokens */
3397
+ declare const defaultTokens: ThemeTokens;
3398
+ /** 默认主题(深色背景) */
3399
+ declare const defaultTheme: Theme;
3400
+ /** Manim/3B1B 风格主题 */
3401
+ declare const manimTheme: Theme;
3402
+ /** 浅色主题 */
3403
+ declare const lightTheme: Theme;
3404
+ /**
3405
+ * 创建自定义主题
3406
+ *
3407
+ * @param name 主题名称
3408
+ * @param overrides 要覆盖的 tokens
3409
+ * @param baseTheme 基础主题(默认为 defaultTheme)
3410
+ * @returns 新的主题
3411
+ *
3412
+ * @example
3413
+ * ```typescript
3414
+ * const myTheme = createTheme('custom', {
3415
+ * color: {
3416
+ * semantic: { primary: '#FF0000' }
3417
+ * },
3418
+ * stroke: {
3419
+ * width: { default: 3 }
3420
+ * }
3421
+ * });
3422
+ * ```
3423
+ */
3424
+ declare function createTheme(name: string, overrides: ThemeOverrides, baseTheme?: Theme): Theme;
3425
+ /** 所有预定义主题 */
3426
+ declare const themes: {
3427
+ readonly default: Theme;
3428
+ readonly manim: Theme;
3429
+ readonly light: Theme;
3430
+ };
3431
+ /** 主题名称类型 */
3432
+ type ThemeName = keyof typeof themes;
3433
+ /**
3434
+ * 根据名称获取主题
3435
+ */
3436
+ declare function getTheme(name: ThemeName): Theme;
3437
+
3438
+ /**
3439
+ * @locusing/theme - 主题上下文
3440
+ *
3441
+ * 提供全局主题管理和样式生成工具
3442
+ */
3443
+
3444
+ /**
3445
+ * 获取当前主题
3446
+ */
3447
+ declare function getCurrentTheme(): Theme;
3448
+ /**
3449
+ * 设置当前主题
3450
+ */
3451
+ declare function setCurrentTheme(theme: Theme): void;
3452
+ /**
3453
+ * 使用主题覆盖创建临时主题并设置
3454
+ */
3455
+ declare function applyThemeOverrides(overrides: ThemeOverrides): Theme;
3456
+ /**
3457
+ * 重置为默认主题
3458
+ */
3459
+ declare function resetTheme(): void;
3460
+ /**
3461
+ * 从当前主题获取默认描边样式
3462
+ */
3463
+ declare function getDefaultStrokeStyle(): Style;
3464
+ /**
3465
+ * 从当前主题获取默认填充样式
3466
+ */
3467
+ declare function getDefaultFillStyle(): Style;
3468
+ /**
3469
+ * 从当前主题获取默认文本样式
3470
+ */
3471
+ declare function getDefaultTextStyle(): TextStyle;
3472
+ /**
3473
+ * 获取主题 tokens
3474
+ */
3475
+ declare function getTokens(): ThemeTokens;
3476
+ /**
3477
+ * 创建基于语义颜色的样式
3478
+ */
3479
+ declare function semanticStyle(semantic: keyof ThemeTokens['color']['semantic'], options?: {
3480
+ filled?: boolean;
3481
+ strokeWidth?: keyof ThemeTokens['stroke']['width'];
3482
+ opacity?: number;
3483
+ }): Style;
3484
+ /**
3485
+ * 创建虚线样式
3486
+ */
3487
+ declare function dashedStyle(pattern?: keyof ThemeTokens['stroke']['dash'], options?: {
3488
+ color?: string;
3489
+ strokeWidth?: keyof ThemeTokens['stroke']['width'];
3490
+ }): Style;
3491
+ /**
3492
+ * 创建坐标轴样式(X/Y/Z)
3493
+ */
3494
+ declare function axisColorStyle(axis: 'x' | 'y' | 'z', options?: {
3495
+ filled?: boolean;
3496
+ strokeWidth?: keyof ThemeTokens['stroke']['width'];
3497
+ }): Style;
3498
+ /**
3499
+ * 获取动画时长
3500
+ */
3501
+ declare function getDuration(speed?: keyof ThemeTokens['animation']['duration']): number;
3502
+ /**
3503
+ * 获取缓动函数
3504
+ */
3505
+ declare function getEasing(type?: keyof ThemeTokens['animation']['easing']): string;
3506
+ /**
3507
+ * 获取间距值
3508
+ */
3509
+ declare function getSpacing(size?: keyof ThemeTokens['layout']['spacing']): number;
3510
+ /**
3511
+ * 获取默认 buffer 值
3512
+ */
3513
+ declare function getBuffer(): number;
3514
+
3515
+ /**
3516
+ * Graph - 图论可视化
3517
+ *
3518
+ * 支持无向图和有向图的可视化
3519
+ */
3520
+
3521
+ /**
3522
+ * 顶点配置
3523
+ */
3524
+ interface VertexConfig {
3525
+ /** 顶点半径 */
3526
+ radius?: number;
3527
+ /** 顶点颜色 */
3528
+ color?: string;
3529
+ /** 标签字体大小 */
3530
+ labelSize?: number;
3531
+ /** 标签颜色 */
3532
+ labelColor?: string;
3533
+ }
3534
+ /**
3535
+ * 边配置
3536
+ */
3537
+ interface EdgeConfig {
3538
+ /** 边宽度 */
3539
+ strokeWidth?: number;
3540
+ /** 边颜色 */
3541
+ color?: string;
3542
+ /** 是否弯曲 */
3543
+ curved?: boolean;
3544
+ /** 弯曲程度 */
3545
+ curvature?: number;
3546
+ /** 箭头大小(有向图) */
3547
+ headSize?: number;
3548
+ }
3549
+ /**
3550
+ * 布局类型
3551
+ */
3552
+ type LayoutType = 'circular' | 'spring' | 'tree' | 'grid' | 'random';
3553
+ /**
3554
+ * 自定义布局函数
3555
+ */
3556
+ type LayoutFunction = (vertices: string[], edges: [string, string][]) => Map<string, Vector2>;
3557
+ /**
3558
+ * 图配置
3559
+ */
3560
+ interface GraphConfig {
3561
+ /** 顶点列表 */
3562
+ vertices: string[] | number;
3563
+ /** 边列表 */
3564
+ edges: [string | number, string | number][];
3565
+ /** 布局类型或自定义布局函数 */
3566
+ layout?: LayoutType | LayoutFunction;
3567
+ /** 是否有向图 */
3568
+ directed?: boolean;
3569
+ /** 是否显示标签 */
3570
+ labels?: boolean;
3571
+ /** 顶点配置 */
3572
+ vertexConfig?: VertexConfig;
3573
+ /** 边配置 */
3574
+ edgeConfig?: EdgeConfig;
3575
+ /** 布局缩放 */
3576
+ scale?: number;
3577
+ /** 布局中心 */
3578
+ center?: Vector2;
3579
+ }
3580
+ /**
3581
+ * Graph 类
3582
+ *
3583
+ * 表示一个图结构并提供可视化
3584
+ */
3585
+ declare class Graph {
3586
+ protected _vertices: string[];
3587
+ protected _edges: [string, string][];
3588
+ protected _positions: Map<string, Vector2>;
3589
+ protected _directed: boolean;
3590
+ protected _showLabels: boolean;
3591
+ protected _vertexConfig: Required<VertexConfig>;
3592
+ protected _edgeConfig: Required<EdgeConfig>;
3593
+ protected _scale: number;
3594
+ protected _center: Vector2;
3595
+ constructor(config: GraphConfig);
3596
+ /**
3597
+ * 计算布局
3598
+ */
3599
+ protected computeLayout(layout?: LayoutType | LayoutFunction): Map<string, Vector2>;
3600
+ /**
3601
+ * 获取顶点位置
3602
+ */
3603
+ getVertexPosition(id: string): Vector2 | undefined;
3604
+ /**
3605
+ * 设置顶点位置
3606
+ */
3607
+ setVertexPosition(id: string, position: Vector2): this;
3608
+ /**
3609
+ * 获取所有顶点
3610
+ */
3611
+ getVertices(): string[];
3612
+ /**
3613
+ * 获取所有边
3614
+ */
3615
+ getEdges(): [string, string][];
3616
+ /**
3617
+ * 添加顶点
3618
+ */
3619
+ addVertex(id: string, position?: Vector2): this;
3620
+ /**
3621
+ * 添加边
3622
+ */
3623
+ addEdge(from: string, to: string): this;
3624
+ /**
3625
+ * 移除顶点
3626
+ */
3627
+ removeVertex(id: string): this;
3628
+ /**
3629
+ * 移除边
3630
+ */
3631
+ removeEdge(from: string, to: string): this;
3632
+ /**
3633
+ * 高亮路径
3634
+ */
3635
+ highlightPath(path: string[], color?: string): Diagram;
3636
+ /**
3637
+ * 转换为 Diagram
3638
+ */
3639
+ toDiagram(): Diagram;
3640
+ }
3641
+ /**
3642
+ * DiGraph 类 - 有向图
3643
+ */
3644
+ declare class DiGraph extends Graph {
3645
+ constructor(config: Omit<GraphConfig, 'directed'>);
3646
+ /**
3647
+ * 获取入边
3648
+ */
3649
+ getInEdges(vertex: string): [string, string][];
3650
+ /**
3651
+ * 获取出边
3652
+ */
3653
+ getOutEdges(vertex: string): [string, string][];
3654
+ /**
3655
+ * 获取入度
3656
+ */
3657
+ getInDegree(vertex: string): number;
3658
+ /**
3659
+ * 获取出度
3660
+ */
3661
+ getOutDegree(vertex: string): number;
3662
+ }
3663
+ /**
3664
+ * 圆形布局
3665
+ */
3666
+ declare function circularLayout(vertices: string[], scale?: number, startAngle?: number): Map<string, Vector2>;
3667
+ /**
3668
+ * 弹簧布局(力导向)
3669
+ */
3670
+ declare function springLayout(vertices: string[], edges: [string, string][], scale?: number, iterations?: number): Map<string, Vector2>;
3671
+ /**
3672
+ * 树形布局
3673
+ */
3674
+ declare function treeLayout(vertices: string[], edges: [string, string][], scale?: number): Map<string, Vector2>;
3675
+ /**
3676
+ * 网格布局
3677
+ */
3678
+ declare function gridLayout(vertices: string[], scale?: number, columns?: number): Map<string, Vector2>;
3679
+ /**
3680
+ * 随机布局
3681
+ */
3682
+ declare function randomLayout(vertices: string[], scale?: number): Map<string, Vector2>;
3683
+ /**
3684
+ * 创建无向图
3685
+ */
3686
+ declare function graph(config: GraphConfig): Graph;
3687
+ /**
3688
+ * 创建有向图
3689
+ */
3690
+ declare function digraph(config: Omit<GraphConfig, 'directed'>): DiGraph;
3691
+
3692
+ /**
3693
+ * Dagre 布局适配器
3694
+ *
3695
+ * 将 Dagre 的布局算法集成到 Locusing,只使用其计算能力
3696
+ * 渲染仍由 Locusing 统一控制
3697
+ *
3698
+ * 参考: plan/09-integration-principles-unified-rendering.md
3699
+ */
3700
+
3701
+ /** Dagre 布局方向 */
3702
+ type DagreRankDir = 'TB' | 'BT' | 'LR' | 'RL';
3703
+ /** Dagre 边路由模式 */
3704
+ type DagreEdgeRouting = 'polyline' | 'ortho' | 'spline';
3705
+ /** Dagre 节点对齐 */
3706
+ type DagreAlign = 'UL' | 'UR' | 'DL' | 'DR';
3707
+ /** Dagre 排名器算法 */
3708
+ type DagreRanker = 'network-simplex' | 'tight-tree' | 'longest-path';
3709
+ /** Dagre 布局配置 */
3710
+ interface DagreLayoutConfig {
3711
+ /** 布局方向 (TB=上到下, BT=下到上, LR=左到右, RL=右到左) */
3712
+ rankDir?: DagreRankDir;
3713
+ /** 节点对齐方式 */
3714
+ align?: DagreAlign;
3715
+ /** 节点水平间距 */
3716
+ nodeSep?: number;
3717
+ /** 边间距 */
3718
+ edgeSep?: number;
3719
+ /** 层级间距 */
3720
+ rankSep?: number;
3721
+ /** 边距 */
3722
+ marginX?: number;
3723
+ marginY?: number;
3724
+ /** 排名算法 */
3725
+ ranker?: DagreRanker;
3726
+ }
3727
+ /** 边路由点 */
3728
+ interface EdgeRoute {
3729
+ /** 边的起点 */
3730
+ source: string;
3731
+ /** 边的终点 */
3732
+ target: string;
3733
+ /** 路由点列表 */
3734
+ points: Vector2[];
3735
+ }
3736
+ /** Dagre 布局结果 */
3737
+ interface DagreLayoutResult {
3738
+ /** 节点位置 */
3739
+ positions: Map<string, Vector2>;
3740
+ /** 边路由 */
3741
+ routes: EdgeRoute[];
3742
+ /** 图的宽度 */
3743
+ width: number;
3744
+ /** 图的高度 */
3745
+ height: number;
3746
+ }
3747
+ /**
3748
+ * 使用 Dagre 进行层次布局
3749
+ *
3750
+ * @param vertices 顶点 ID 列表
3751
+ * @param edges 边列表 [source, target]
3752
+ * @param config 布局配置
3753
+ * @returns 布局结果(节点位置和边路由)
3754
+ *
3755
+ * @example
3756
+ * ```typescript
3757
+ * const result = dagreLayout(
3758
+ * ['A', 'B', 'C', 'D'],
3759
+ * [['A', 'B'], ['A', 'C'], ['B', 'D'], ['C', 'D']],
3760
+ * { rankDir: 'TB', rankSep: 50 }
3761
+ * );
3762
+ *
3763
+ * // 使用位置创建 Graph
3764
+ * const graph = new Graph({
3765
+ * vertices: ['A', 'B', 'C', 'D'],
3766
+ * edges: [['A', 'B'], ['A', 'C'], ['B', 'D'], ['C', 'D']],
3767
+ * layout: (v, e) => result.positions
3768
+ * });
3769
+ * ```
3770
+ */
3771
+ declare function dagreLayout(vertices: string[], edges: [string, string][], config?: DagreLayoutConfig): DagreLayoutResult;
3772
+ /**
3773
+ * 创建 Dagre 布局函数(适配 Graph.layout 接口)
3774
+ *
3775
+ * @param config 布局配置
3776
+ * @returns 符合 LayoutFunction 签名的函数
3777
+ *
3778
+ * @example
3779
+ * ```typescript
3780
+ * const graph = new Graph({
3781
+ * vertices: ['A', 'B', 'C'],
3782
+ * edges: [['A', 'B'], ['B', 'C']],
3783
+ * layout: createDagreLayoutFn({ rankDir: 'LR' })
3784
+ * });
3785
+ * ```
3786
+ */
3787
+ declare function createDagreLayoutFn(config?: DagreLayoutConfig): (vertices: string[], edges: [string, string][]) => Map<string, Vector2>;
3788
+ /**
3789
+ * 层次布局(简化接口)
3790
+ *
3791
+ * 与现有布局函数保持一致的 API
3792
+ */
3793
+ declare function hierarchicalLayout(vertices: string[], edges: [string, string][], scale?: number, direction?: DagreRankDir): Map<string, Vector2>;
3794
+ /**
3795
+ * 正交布局(适合流程图)
3796
+ */
3797
+ declare function orthogonalLayout(vertices: string[], edges: [string, string][], scale?: number, direction?: DagreRankDir): Map<string, Vector2>;
3798
+ /**
3799
+ * 带分组的层次布局
3800
+ */
3801
+ declare function groupedHierarchicalLayout(vertices: string[], edges: [string, string][], groups: Map<string, string[]>, config?: DagreLayoutConfig): DagreLayoutResult;
3802
+
3803
+ /**
3804
+ * Table - 表格可视化
3805
+ *
3806
+ * 支持数据表格的创建和样式配置
3807
+ */
3808
+
3809
+ /**
3810
+ * 表格配置
3811
+ */
3812
+ interface TableConfig {
3813
+ /** 表格数据 (行 × 列) */
3814
+ data: (string | number | Diagram)[][];
3815
+ /** 行高(统一或每行)*/
3816
+ rowHeights?: number | number[];
3817
+ /** 列宽(统一或每列)*/
3818
+ colWidths?: number | number[];
3819
+ /** 水平线(true=全部, 数组=指定行后) */
3820
+ hLines?: boolean | number[];
3821
+ /** 垂直线(true=全部, 数组=指定列后) */
3822
+ vLines?: boolean | number[];
3823
+ /** 是否有表头行 */
3824
+ headerRow?: boolean;
3825
+ /** 是否有表头列 */
3826
+ headerCol?: boolean;
3827
+ /** 单元格内边距 */
3828
+ cellPadding?: number;
3829
+ /** 字体大小 */
3830
+ fontSize?: number;
3831
+ /** 文字颜色 */
3832
+ textColor?: string;
3833
+ /** 边框颜色 */
3834
+ lineColor?: string;
3835
+ /** 边框宽度 */
3836
+ lineWidth?: number;
3837
+ /** 表头背景色 */
3838
+ headerBackground?: string;
3839
+ /** 交替行背景色 */
3840
+ alternateRowColor?: string;
3841
+ }
3842
+ /**
3843
+ * 表格单元格信息
3844
+ */
3845
+ interface CellInfo {
3846
+ diagram: Diagram;
3847
+ row: number;
3848
+ col: number;
3849
+ x: number;
3850
+ y: number;
3851
+ width: number;
3852
+ height: number;
3853
+ }
3854
+ /**
3855
+ * Table 类 - 表格可视化
3856
+ */
3857
+ declare class Table {
3858
+ protected _data: (string | number | Diagram)[][];
3859
+ protected _rowHeights: number[];
3860
+ protected _colWidths: number[];
3861
+ protected _hLines: number[];
3862
+ protected _vLines: number[];
3863
+ protected _headerRow: boolean;
3864
+ protected _headerCol: boolean;
3865
+ protected _cellPadding: number;
3866
+ protected _fontSize: number;
3867
+ protected _textColor: string;
3868
+ protected _lineColor: string;
3869
+ protected _lineWidth: number;
3870
+ protected _headerBackground: string | undefined;
3871
+ protected _alternateRowColor: string | undefined;
3872
+ protected _cells: CellInfo[][];
3873
+ protected _totalWidth: number;
3874
+ protected _totalHeight: number;
3875
+ /**
3876
+ * 创建表格
3877
+ */
3878
+ constructor(config: TableConfig);
3879
+ /**
3880
+ * 构建单元格
3881
+ */
3882
+ protected buildCells(): CellInfo[][];
3883
+ /**
3884
+ * 获取单元格
3885
+ */
3886
+ getCell(row: number, col: number): Diagram | undefined;
3887
+ /**
3888
+ * 获取整行
3889
+ */
3890
+ getRow(row: number): Diagram[];
3891
+ /**
3892
+ * 获取整列
3893
+ */
3894
+ getCol(col: number): Diagram[];
3895
+ /**
3896
+ * 高亮单元格
3897
+ */
3898
+ highlightCell(row: number, col: number, color?: string): Diagram;
3899
+ /**
3900
+ * 高亮整行
3901
+ */
3902
+ highlightRow(row: number, color?: string): Diagram;
3903
+ /**
3904
+ * 高亮整列
3905
+ */
3906
+ highlightCol(col: number, color?: string): Diagram;
3907
+ /**
3908
+ * 获取行数
3909
+ */
3910
+ get numRows(): number;
3911
+ /**
3912
+ * 获取列数
3913
+ */
3914
+ get numCols(): number;
3915
+ /**
3916
+ * 获取总宽度
3917
+ */
3918
+ get width(): number;
3919
+ /**
3920
+ * 获取总高度
3921
+ */
3922
+ get height(): number;
3923
+ /**
3924
+ * 转换为 Diagram
3925
+ */
3926
+ toDiagram(): Diagram;
3927
+ }
3928
+ /**
3929
+ * 创建表格
3930
+ */
3931
+ declare function table(config: TableConfig): Table;
3932
+ /**
3933
+ * 创建整数表格
3934
+ */
3935
+ declare function integerTable(data: number[][], config?: Omit<TableConfig, 'data'>): Table;
3936
+ /**
3937
+ * 创建小数表格
3938
+ */
3939
+ declare function decimalTable(data: number[][], config?: Omit<TableConfig, 'data'> & {
3940
+ precision?: number;
3941
+ }): Table;
3942
+ /**
3943
+ * 创建数学表格(LaTeX 字符串)
3944
+ */
3945
+ declare function mathTable(data: string[][], config?: Omit<TableConfig, 'data'>): Table;
3946
+
3947
+ /**
3948
+ * Matrix Display - 矩阵可视化
3949
+ *
3950
+ * 支持矩阵的创建和样式配置,包括括号显示
3951
+ */
3952
+
3953
+ /**
3954
+ * 矩阵配置
3955
+ */
3956
+ interface MatrixConfig {
3957
+ /** 矩阵数据 */
3958
+ data: (number | string)[][];
3959
+ /** 括号类型 */
3960
+ brackets?: 'round' | 'square' | 'curly' | 'pipe' | 'none';
3961
+ /** 水平间距 */
3962
+ hBuff?: number;
3963
+ /** 垂直间距 */
3964
+ vBuff?: number;
3965
+ /** 字体大小 */
3966
+ fontSize?: number;
3967
+ /** 文字颜色 */
3968
+ textColor?: string;
3969
+ /** 括号颜色 */
3970
+ bracketColor?: string;
3971
+ /** 括号宽度 */
3972
+ bracketWidth?: number;
3973
+ }
3974
+ /**
3975
+ * 矩阵元素信息
3976
+ */
3977
+ interface EntryInfo {
3978
+ diagram: Diagram;
3979
+ row: number;
3980
+ col: number;
3981
+ x: number;
3982
+ y: number;
3983
+ }
3984
+ /**
3985
+ * MatrixDisplay 类 - 矩阵可视化
3986
+ */
3987
+ declare class MatrixDisplay {
3988
+ protected _data: (number | string)[][];
3989
+ protected _brackets: 'round' | 'square' | 'curly' | 'pipe' | 'none';
3990
+ protected _hBuff: number;
3991
+ protected _vBuff: number;
3992
+ protected _fontSize: number;
3993
+ protected _textColor: string;
3994
+ protected _bracketColor: string;
3995
+ protected _bracketWidth: number;
3996
+ protected _entries: EntryInfo[][];
3997
+ protected _numRows: number;
3998
+ protected _numCols: number;
3999
+ protected _contentWidth: number;
4000
+ protected _contentHeight: number;
4001
+ /**
4002
+ * 创建矩阵显示
4003
+ */
4004
+ constructor(config: MatrixConfig);
4005
+ /**
4006
+ * 构建矩阵条目
4007
+ */
4008
+ protected buildEntries(): EntryInfo[][];
4009
+ /**
4010
+ * 获取矩阵元素
4011
+ */
4012
+ getEntry(row: number, col: number): Diagram | undefined;
4013
+ /**
4014
+ * 获取整行
4015
+ */
4016
+ getRow(row: number): Diagram[];
4017
+ /**
4018
+ * 获取整列
4019
+ */
4020
+ getColumn(col: number): Diagram[];
4021
+ /**
4022
+ * 高亮元素
4023
+ */
4024
+ highlightEntry(row: number, col: number, color?: string): Diagram;
4025
+ /**
4026
+ * 获取括号
4027
+ */
4028
+ getBrackets(): [Diagram, Diagram];
4029
+ /**
4030
+ * 获取行数
4031
+ */
4032
+ get numRows(): number;
4033
+ /**
4034
+ * 获取列数
4035
+ */
4036
+ get numCols(): number;
4037
+ /**
4038
+ * 获取总宽度
4039
+ */
4040
+ get width(): number;
4041
+ /**
4042
+ * 获取总高度
4043
+ */
4044
+ get height(): number;
4045
+ /**
4046
+ * 转换为 Diagram
4047
+ */
4048
+ toDiagram(): Diagram;
4049
+ }
4050
+ /**
4051
+ * 创建矩阵显示
4052
+ */
4053
+ declare function matrix(data: (number | string)[][], config?: Omit<MatrixConfig, 'data'>): MatrixDisplay;
4054
+ /**
4055
+ * 创建整数矩阵
4056
+ */
4057
+ declare function integerMatrix(data: number[][], config?: Omit<MatrixConfig, 'data'>): MatrixDisplay;
4058
+ /**
4059
+ * 创建小数矩阵
4060
+ */
4061
+ declare function decimalMatrix(data: number[][], config?: Omit<MatrixConfig, 'data'> & {
4062
+ precision?: number;
4063
+ }): MatrixDisplay;
4064
+ /**
4065
+ * 创建行列式
4066
+ */
4067
+ declare function determinant(data: number[][], config?: Omit<MatrixConfig, 'data' | 'brackets'>): MatrixDisplay;
4068
+
4069
+ /**
4070
+ * D3 Scale 适配器
4071
+ *
4072
+ * 遵循 "Compute-first" 原则:
4073
+ * - D3 只负责计算比例尺映射
4074
+ * - Locusing 负责所有渲染
4075
+ */
4076
+ /** 比例尺基础接口 */
4077
+ interface Scale<Domain, Range> {
4078
+ /** 将域值映射到范围值 */
4079
+ (value: Domain): Range;
4080
+ /** 获取域 */
4081
+ domain(): Domain[];
4082
+ /** 获取范围 */
4083
+ range(): Range[];
4084
+ /** 复制比例尺 */
4085
+ copy(): Scale<Domain, Range>;
4086
+ }
4087
+ /** 连续比例尺(支持反转和插值) */
4088
+ interface ContinuousScale extends Scale<number, number> {
4089
+ /** 将范围值反转映射到域值 */
4090
+ invert(value: number): number;
4091
+ /** 生成刻度值 */
4092
+ ticks(count?: number): number[];
4093
+ /** 格式化刻度标签 */
4094
+ tickFormat(count?: number, specifier?: string): (d: number) => string;
4095
+ /** 设置是否截断到范围 */
4096
+ clamp(clamp: boolean): ContinuousScale;
4097
+ /** 设置是否使用漂亮的域值 */
4098
+ nice(count?: number): ContinuousScale;
4099
+ }
4100
+ /** 序数比例尺 */
4101
+ interface OrdinalScale<Domain extends string | number> extends Scale<Domain, string> {
4102
+ /** 未知值的返回值 */
4103
+ unknown(): string | undefined;
4104
+ }
4105
+ /** 带状比例尺(用于柱状图) */
4106
+ interface BandScale<Domain extends string | number> extends Scale<Domain, number> {
4107
+ /** 获取带宽 */
4108
+ bandwidth(): number;
4109
+ /** 获取步长 */
4110
+ step(): number;
4111
+ /** 设置内边距 */
4112
+ paddingInner(padding: number): BandScale<Domain>;
4113
+ /** 设置外边距 */
4114
+ paddingOuter(padding: number): BandScale<Domain>;
4115
+ /** 设置对齐方式 */
4116
+ align(align: number): BandScale<Domain>;
4117
+ }
4118
+ /** 点比例尺 */
4119
+ interface PointScale<Domain extends string | number> extends Scale<Domain, number> {
4120
+ /** 获取步长 */
4121
+ step(): number;
4122
+ /** 设置外边距 */
4123
+ padding(padding: number): PointScale<Domain>;
4124
+ /** 设置对齐方式 */
4125
+ align(align: number): PointScale<Domain>;
4126
+ }
4127
+ /** 比例尺配置 */
4128
+ interface ScaleConfig<Domain, Range> {
4129
+ domain: Domain[];
4130
+ range: Range[];
4131
+ }
4132
+ /** 连续比例尺配置 */
4133
+ interface ContinuousScaleConfig extends ScaleConfig<number, number> {
4134
+ clamp?: boolean;
4135
+ nice?: boolean | number;
4136
+ }
4137
+ /** 带状比例尺配置 */
4138
+ interface BandScaleConfig<D extends string | number> extends ScaleConfig<D, number> {
4139
+ paddingInner?: number;
4140
+ paddingOuter?: number;
4141
+ align?: number;
4142
+ }
4143
+ /**
4144
+ * 创建线性比例尺
4145
+ *
4146
+ * @example
4147
+ * ```ts
4148
+ * const x = linearScale({ domain: [0, 100], range: [0, 800] });
4149
+ * x(50); // 400
4150
+ * x.invert(400); // 50
4151
+ * x.ticks(5); // [0, 20, 40, 60, 80, 100]
4152
+ * ```
4153
+ */
4154
+ declare function linearScale(config: ContinuousScaleConfig): ContinuousScale;
4155
+ /**
4156
+ * 创建对数比例尺
4157
+ *
4158
+ * @example
4159
+ * ```ts
4160
+ * const x = logScale({ domain: [1, 1000], range: [0, 300] });
4161
+ * x(10); // 100
4162
+ * x(100); // 200
4163
+ * ```
4164
+ */
4165
+ declare function logScale(config: ContinuousScaleConfig & {
4166
+ base?: number;
4167
+ }): ContinuousScale;
4168
+ /**
4169
+ * 创建幂比例尺
4170
+ *
4171
+ * @example
4172
+ * ```ts
4173
+ * const x = powScale({ domain: [0, 100], range: [0, 400], exponent: 2 });
4174
+ * x(50); // 100 (因为 (50/100)^2 * 400 = 100)
4175
+ * ```
4176
+ */
4177
+ declare function powScale(config: ContinuousScaleConfig & {
4178
+ exponent?: number;
4179
+ }): ContinuousScale;
4180
+ /**
4181
+ * 创建平方根比例尺(指数为 0.5 的幂比例尺)
4182
+ *
4183
+ * @example
4184
+ * ```ts
4185
+ * const radius = sqrtScale({ domain: [0, 100], range: [0, 50] });
4186
+ * // 用于气泡图:面积与数据成正比
4187
+ * ```
4188
+ */
4189
+ declare function sqrtScale(config: ContinuousScaleConfig): ContinuousScale;
4190
+ /**
4191
+ * 创建序数比例尺
4192
+ *
4193
+ * @example
4194
+ * ```ts
4195
+ * const color = ordinalScale({
4196
+ * domain: ['A', 'B', 'C'],
4197
+ * range: ['#ff0000', '#00ff00', '#0000ff']
4198
+ * });
4199
+ * color('A'); // '#ff0000'
4200
+ * color('B'); // '#00ff00'
4201
+ * ```
4202
+ */
4203
+ declare function ordinalScale<D extends string | number>(config: ScaleConfig<D, string>): OrdinalScale<D>;
4204
+ /**
4205
+ * 创建带状比例尺(用于柱状图)
4206
+ *
4207
+ * @example
4208
+ * ```ts
4209
+ * const x = bandScale({
4210
+ * domain: ['A', 'B', 'C', 'D'],
4211
+ * range: [0, 400],
4212
+ * paddingInner: 0.1
4213
+ * });
4214
+ * x('A'); // 柱子起始位置
4215
+ * x.bandwidth(); // 柱子宽度
4216
+ * ```
4217
+ */
4218
+ declare function bandScale<D extends string | number>(config: BandScaleConfig<D>): BandScale<D>;
4219
+ /**
4220
+ * 创建点比例尺(用于散点图离散轴)
4221
+ *
4222
+ * @example
4223
+ * ```ts
4224
+ * const x = pointScale({
4225
+ * domain: ['Q1', 'Q2', 'Q3', 'Q4'],
4226
+ * range: [0, 300]
4227
+ * });
4228
+ * x('Q1'); // 第一个点的位置
4229
+ * x.step(); // 点之间的间距
4230
+ * ```
4231
+ */
4232
+ declare function pointScale<D extends string | number>(config: ScaleConfig<D, number> & {
4233
+ padding?: number;
4234
+ align?: number;
4235
+ }): PointScale<D>;
4236
+ /** 预设颜色方案 */
4237
+ type ColorScheme = 'category10' | 'accent' | 'dark2' | 'paired' | 'pastel1' | 'pastel2' | 'set1' | 'set2' | 'set3' | 'tableau10';
4238
+ /**
4239
+ * 创建分类颜色比例尺
4240
+ *
4241
+ * @example
4242
+ * ```ts
4243
+ * const color = categoryScale(['A', 'B', 'C'], 'category10');
4244
+ * color('A'); // '#1f77b4'
4245
+ * color('B'); // '#ff7f0e'
4246
+ * ```
4247
+ */
4248
+ declare function categoryScale<D extends string | number>(domain: D[], scheme?: ColorScheme): OrdinalScale<D>;
4249
+ /**
4250
+ * 创建坐标轴比例尺对
4251
+ *
4252
+ * @example
4253
+ * ```ts
4254
+ * const { x, y } = createAxisScales({
4255
+ * xDomain: [0, 100],
4256
+ * yDomain: [0, 50],
4257
+ * width: 800,
4258
+ * height: 400,
4259
+ * margin: { left: 40, right: 20, top: 20, bottom: 30 }
4260
+ * });
4261
+ * ```
4262
+ */
4263
+ declare function createAxisScales(config: {
4264
+ xDomain: [number, number];
4265
+ yDomain: [number, number];
4266
+ width: number;
4267
+ height: number;
4268
+ margin?: {
4269
+ left?: number;
4270
+ right?: number;
4271
+ top?: number;
4272
+ bottom?: number;
4273
+ };
4274
+ xNice?: boolean;
4275
+ yNice?: boolean;
4276
+ }): {
4277
+ x: ContinuousScale;
4278
+ y: ContinuousScale;
4279
+ };
4280
+
4281
+ /**
4282
+ * D3 Shape 适配器
4283
+ *
4284
+ * 遵循 "Compute-first" 原则:
4285
+ * - D3 只负责计算形状的几何数据
4286
+ * - Locusing 负责所有渲染
4287
+ *
4288
+ * 与 D3 不同的是,这些函数返回坐标点数组而非 SVG 路径字符串
4289
+ */
4290
+
4291
+ /** 数据点 */
4292
+ interface DataPoint {
4293
+ x: number;
4294
+ y: number;
4295
+ [key: string]: unknown;
4296
+ }
4297
+ /** 曲线类型 */
4298
+ type CurveType = 'linear' | 'step' | 'stepBefore' | 'stepAfter' | 'basis' | 'cardinal' | 'catmullRom' | 'monotoneX' | 'monotoneY' | 'natural';
4299
+ /** 折线配置 */
4300
+ interface LineConfig<T = DataPoint> {
4301
+ /** X 值访问器 */
4302
+ x?: (d: T, i: number) => number;
4303
+ /** Y 值访问器 */
4304
+ y?: (d: T, i: number) => number;
4305
+ /** 是否定义(用于过滤无效点) */
4306
+ defined?: (d: T, i: number) => boolean;
4307
+ /** 曲线类型 */
4308
+ curve?: CurveType;
4309
+ /** Cardinal/CatmullRom 张力参数 */
4310
+ tension?: number;
4311
+ }
4312
+ /** 面积配置 */
4313
+ interface AreaConfig<T = DataPoint> {
4314
+ /** X 值访问器 */
4315
+ x?: (d: T, i: number) => number;
4316
+ /** Y0 值访问器(基线) */
4317
+ y0?: (d: T, i: number) => number;
4318
+ /** Y1 值访问器(顶线) */
4319
+ y1?: (d: T, i: number) => number;
4320
+ /** 是否定义 */
4321
+ defined?: (d: T, i: number) => boolean;
4322
+ /** 曲线类型 */
4323
+ curve?: CurveType;
4324
+ /** 张力参数 */
4325
+ tension?: number;
4326
+ }
4327
+ /** 弧形配置 */
4328
+ interface ArcConfig {
4329
+ /** 内半径 */
4330
+ innerRadius: number;
4331
+ /** 外半径 */
4332
+ outerRadius: number;
4333
+ /** 起始角度(弧度) */
4334
+ startAngle: number;
4335
+ /** 结束角度(弧度) */
4336
+ endAngle: number;
4337
+ /** 填充角度 */
4338
+ padAngle?: number;
4339
+ /** 圆角半径 */
4340
+ cornerRadius?: number;
4341
+ }
4342
+ /** 饼图数据 */
4343
+ interface PieData<T = unknown> {
4344
+ data: T;
4345
+ value: number;
4346
+ index: number;
4347
+ startAngle: number;
4348
+ endAngle: number;
4349
+ padAngle: number;
4350
+ }
4351
+ /** 饼图配置 */
4352
+ interface PieConfig<T = number> {
4353
+ /** 值访问器 */
4354
+ value?: (d: T, i: number) => number;
4355
+ /** 排序比较器 */
4356
+ sort?: ((a: T, b: T) => number) | null;
4357
+ /** 按值排序 */
4358
+ sortValues?: ((a: number, b: number) => number) | null;
4359
+ /** 起始角度 */
4360
+ startAngle?: number;
4361
+ /** 结束角度 */
4362
+ endAngle?: number;
4363
+ /** 填充角度 */
4364
+ padAngle?: number;
4365
+ }
4366
+ /** 堆叠数据 */
4367
+ interface StackData<T = Record<string, number>> {
4368
+ key: string;
4369
+ index: number;
4370
+ data: Array<[number, number, T]>;
4371
+ }
4372
+ /** 堆叠配置 */
4373
+ interface StackConfig<T = Record<string, number>> {
4374
+ /** 键列表 */
4375
+ keys: string[];
4376
+ /** 值访问器 */
4377
+ value?: (d: T, key: string) => number;
4378
+ /** 排序键 */
4379
+ order?: 'none' | 'ascending' | 'descending' | 'insideOut' | 'reverse';
4380
+ /** 偏移类型 */
4381
+ offset?: 'none' | 'expand' | 'diverging' | 'silhouette' | 'wiggle';
4382
+ }
4383
+ /** 面积结果 */
4384
+ interface AreaResult {
4385
+ /** 顶线点 */
4386
+ topLine: Vector2[];
4387
+ /** 底线点 */
4388
+ bottomLine: Vector2[];
4389
+ /** 闭合多边形(顶线 + 反转底线) */
4390
+ polygon: Vector2[];
4391
+ }
4392
+ /**
4393
+ * 生成折线点序列
4394
+ *
4395
+ * @example
4396
+ * ```ts
4397
+ * const data = [
4398
+ * { x: 0, y: 10 },
4399
+ * { x: 1, y: 20 },
4400
+ * { x: 2, y: 15 },
4401
+ * { x: 3, y: 25 }
4402
+ * ];
4403
+ *
4404
+ * const points = linePoints(data, {
4405
+ * x: d => xScale(d.x),
4406
+ * y: d => yScale(d.y),
4407
+ * curve: 'monotoneX'
4408
+ * });
4409
+ *
4410
+ * // 使用 Locusing 渲染
4411
+ * const line = Curve.from_points(points);
4412
+ * ```
4413
+ */
4414
+ declare function linePoints<T = DataPoint>(data: T[], config?: LineConfig<T>): Vector2[];
4415
+ /**
4416
+ * 生成多段折线(支持数据中断)
4417
+ *
4418
+ * @example
4419
+ * ```ts
4420
+ * const data = [
4421
+ * { x: 0, y: 10, valid: true },
4422
+ * { x: 1, y: null, valid: false }, // 中断
4423
+ * { x: 2, y: 15, valid: true },
4424
+ * { x: 3, y: 25, valid: true }
4425
+ * ];
4426
+ *
4427
+ * const segments = lineSegments(data, {
4428
+ * defined: d => d.valid,
4429
+ * x: d => d.x,
4430
+ * y: d => d.y ?? 0
4431
+ * });
4432
+ * // 返回两段: [[p0], [p2, p3]]
4433
+ * ```
4434
+ */
4435
+ declare function lineSegments<T = DataPoint>(data: T[], config?: LineConfig<T>): Vector2[][];
4436
+ /**
4437
+ * 生成面积图数据
4438
+ *
4439
+ * @example
4440
+ * ```ts
4441
+ * const data = [
4442
+ * { x: 0, y: 10 },
4443
+ * { x: 1, y: 20 },
4444
+ * { x: 2, y: 15 }
4445
+ * ];
4446
+ *
4447
+ * const area = areaPoints(data, {
4448
+ * x: d => xScale(d.x),
4449
+ * y0: () => yScale(0), // 基线
4450
+ * y1: d => yScale(d.y), // 数据线
4451
+ * curve: 'monotoneX'
4452
+ * });
4453
+ *
4454
+ * // 使用闭合多边形渲染
4455
+ * const polygon = Polygon.from_points(area.polygon);
4456
+ * ```
4457
+ */
4458
+ declare function areaPoints<T = DataPoint>(data: T[], config?: AreaConfig<T>): AreaResult;
4459
+ /**
4460
+ * 生成弧形路径点
4461
+ *
4462
+ * @example
4463
+ * ```ts
4464
+ * const arc = arcPoints({
4465
+ * innerRadius: 50,
4466
+ * outerRadius: 100,
4467
+ * startAngle: 0,
4468
+ * endAngle: Math.PI / 2
4469
+ * });
4470
+ *
4471
+ * const polygon = Polygon.from_points(arc);
4472
+ * ```
4473
+ */
4474
+ declare function arcPoints(config: ArcConfig): Vector2[];
4475
+ /**
4476
+ * 计算弧形质心(用于标签定位)
4477
+ */
4478
+ declare function arcCentroid(config: ArcConfig): Vector2;
4479
+ /**
4480
+ * 生成饼图布局数据
4481
+ *
4482
+ * @example
4483
+ * ```ts
4484
+ * const data = [30, 50, 20];
4485
+ * const slices = pieLayout(data);
4486
+ *
4487
+ * slices.forEach(slice => {
4488
+ * const points = arcPoints({
4489
+ * innerRadius: 0,
4490
+ * outerRadius: 100,
4491
+ * startAngle: slice.startAngle,
4492
+ * endAngle: slice.endAngle
4493
+ * });
4494
+ * // 渲染每个扇形
4495
+ * });
4496
+ * ```
4497
+ */
4498
+ declare function pieLayout<T = number>(data: T[], config?: PieConfig<T>): PieData<T>[];
4499
+ /**
4500
+ * 创建圆环图数据
4501
+ *
4502
+ * @example
4503
+ * ```ts
4504
+ * const data = [
4505
+ * { label: 'A', value: 30 },
4506
+ * { label: 'B', value: 50 },
4507
+ * { label: 'C', value: 20 }
4508
+ * ];
4509
+ *
4510
+ * const donut = donutLayout(data, {
4511
+ * value: d => d.value,
4512
+ * innerRadius: 50,
4513
+ * outerRadius: 100
4514
+ * });
4515
+ *
4516
+ * donut.forEach(({ slice, points, centroid }) => {
4517
+ * // points: 弧形多边形
4518
+ * // centroid: 标签位置
4519
+ * });
4520
+ * ```
4521
+ */
4522
+ declare function donutLayout<T>(data: T[], config: PieConfig<T> & {
4523
+ innerRadius: number;
4524
+ outerRadius: number;
4525
+ }): Array<{
4526
+ slice: PieData<T>;
4527
+ points: Vector2[];
4528
+ centroid: Vector2;
4529
+ }>;
4530
+ /**
4531
+ * 计算堆叠数据
4532
+ *
4533
+ * @example
4534
+ * ```ts
4535
+ * const data = [
4536
+ * { month: 'Jan', a: 10, b: 20, c: 15 },
4537
+ * { month: 'Feb', a: 15, b: 25, c: 20 },
4538
+ * { month: 'Mar', a: 20, b: 15, c: 25 }
4539
+ * ];
4540
+ *
4541
+ * const stacked = stackLayout(data, {
4542
+ * keys: ['a', 'b', 'c'],
4543
+ * offset: 'none'
4544
+ * });
4545
+ *
4546
+ * // 每个系列的堆叠区域
4547
+ * stacked.forEach(series => {
4548
+ * series.data.forEach(([y0, y1, originalData]) => {
4549
+ * // y0: 底部, y1: 顶部
4550
+ * });
4551
+ * });
4552
+ * ```
4553
+ */
4554
+ declare function stackLayout<T extends Record<string, unknown> = Record<string, number>>(data: T[], config: StackConfig<T>): StackData<T>[];
4555
+ /**
4556
+ * 生成堆叠面积图数据
4557
+ */
4558
+ declare function stackedAreaPoints<T extends Record<string, unknown>>(data: T[], config: StackConfig<T> & {
4559
+ x: (d: T, i: number) => number;
4560
+ y: (value: number) => number;
4561
+ curve?: CurveType;
4562
+ }): Map<string, AreaResult>;
4563
+ /**
4564
+ * 对贝塞尔曲线进行细分采样
4565
+ *
4566
+ * @example
4567
+ * ```ts
4568
+ * const points = sampleCubicBezier(
4569
+ * [0, 0], [1, 2], [3, 2], [4, 0],
4570
+ * 20 // 采样点数
4571
+ * );
4572
+ * ```
4573
+ */
4574
+ declare function sampleCubicBezier(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, samples?: number): Vector2[];
4575
+
4576
+ /**
4577
+ * D3 Array 适配器
4578
+ *
4579
+ * 遵循 "Compute-first" 原则:
4580
+ * - D3 只负责数据计算和转换
4581
+ * - Locusing 负责所有渲染
4582
+ */
4583
+ /** 范围 */
4584
+ type Extent<T> = [T, T] | [undefined, undefined];
4585
+ /** 分箱配置 */
4586
+ interface BinConfig<T = number> {
4587
+ /** 值访问器 */
4588
+ value?: (d: T) => number;
4589
+ /** 阈值数量或数组 */
4590
+ thresholds?: number | number[] | ((values: number[]) => number[]);
4591
+ /** 域范围 */
4592
+ domain?: [number, number];
4593
+ }
4594
+ /** 分箱结果 */
4595
+ interface Bin<T = number> {
4596
+ /** 箱内数据 */
4597
+ data: T[];
4598
+ /** 箱起始值 */
4599
+ x0: number;
4600
+ /** 箱结束值 */
4601
+ x1: number;
4602
+ /** 数据数量 */
4603
+ length: number;
4604
+ }
4605
+ /** 分组配置 */
4606
+ interface GroupConfig<T, K extends string | number = string> {
4607
+ /** 分组键访问器 */
4608
+ key: (d: T) => K;
4609
+ /** 值访问器(可选) */
4610
+ value?: (d: T) => number;
4611
+ /** 聚合方法 */
4612
+ aggregate?: 'sum' | 'mean' | 'count' | 'min' | 'max' | 'median';
4613
+ }
4614
+ /** 分组结果 */
4615
+ interface GroupResult<T, K extends string | number = string> {
4616
+ key: K;
4617
+ values: T[];
4618
+ aggregate?: number;
4619
+ }
4620
+ /** 滚动计算配置 */
4621
+ interface RollingConfig {
4622
+ /** 窗口大小 */
4623
+ window: number;
4624
+ /** 计算类型 */
4625
+ type: 'mean' | 'sum' | 'min' | 'max' | 'median';
4626
+ /** 是否居中窗口 */
4627
+ center?: boolean;
4628
+ }
4629
+ /**
4630
+ * 计算数值范围
4631
+ *
4632
+ * @example
4633
+ * ```ts
4634
+ * const data = [3, 1, 4, 1, 5, 9, 2, 6];
4635
+ * const [min, max] = extent(data); // [1, 9]
4636
+ *
4637
+ * // 带访问器
4638
+ * const points = [{ x: 1, y: 5 }, { x: 3, y: 2 }];
4639
+ * const [minY, maxY] = extent(points, d => d.y); // [2, 5]
4640
+ * ```
4641
+ */
4642
+ declare function extent<T>(data: T[], accessor?: (d: T) => number): Extent<number>;
4643
+ /**
4644
+ * 计算最小值
4645
+ */
4646
+ declare function min<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4647
+ /**
4648
+ * 计算最大值
4649
+ */
4650
+ declare function max<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4651
+ /**
4652
+ * 计算总和
4653
+ */
4654
+ declare function sum<T>(data: T[], accessor?: (d: T) => number): number;
4655
+ /**
4656
+ * 计算平均值
4657
+ */
4658
+ declare function mean<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4659
+ /**
4660
+ * 计算中位数
4661
+ */
4662
+ declare function median<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4663
+ /**
4664
+ * 计算分位数
4665
+ *
4666
+ * @example
4667
+ * ```ts
4668
+ * const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
4669
+ * quantile(data, 0.25); // Q1 = 3
4670
+ * quantile(data, 0.5); // Q2 = 5.5
4671
+ * quantile(data, 0.75); // Q3 = 8
4672
+ * ```
4673
+ */
4674
+ declare function quantile<T>(data: T[], p: number, accessor?: (d: T) => number): number | undefined;
4675
+ /**
4676
+ * 计算方差
4677
+ */
4678
+ declare function variance<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4679
+ /**
4680
+ * 计算标准差
4681
+ */
4682
+ declare function deviation<T>(data: T[], accessor?: (d: T) => number): number | undefined;
4683
+ /**
4684
+ * 对数据进行分箱(用于直方图)
4685
+ *
4686
+ * @example
4687
+ * ```ts
4688
+ * const data = [1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10];
4689
+ *
4690
+ * const bins = histogram(data, { thresholds: 5 });
4691
+ * // 返回 5 个箱,每个箱包含落入范围的数据
4692
+ *
4693
+ * bins.forEach(bin => {
4694
+ * const barWidth = xScale(bin.x1) - xScale(bin.x0);
4695
+ * const barHeight = yScale(bin.length);
4696
+ * // 渲染柱状图
4697
+ * });
4698
+ * ```
4699
+ */
4700
+ declare function histogram<T = number>(data: T[], config?: BinConfig<T>): Bin<T>[];
4701
+ /**
4702
+ * 自动计算漂亮的分箱阈值
4703
+ *
4704
+ * @example
4705
+ * ```ts
4706
+ * const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
4707
+ * const thresholds = niceThresholds(data, 5);
4708
+ * // 可能返回 [0, 2, 4, 6, 8, 10]
4709
+ * ```
4710
+ */
4711
+ declare function niceThresholds(data: number[], count?: number): number[];
4712
+ /**
4713
+ * 按键分组数据
4714
+ *
4715
+ * @example
4716
+ * ```ts
4717
+ * const sales = [
4718
+ * { product: 'A', amount: 100 },
4719
+ * { product: 'B', amount: 200 },
4720
+ * { product: 'A', amount: 150 },
4721
+ * { product: 'B', amount: 100 }
4722
+ * ];
4723
+ *
4724
+ * const grouped = group(sales, {
4725
+ * key: d => d.product,
4726
+ * value: d => d.amount,
4727
+ * aggregate: 'sum'
4728
+ * });
4729
+ * // [{ key: 'A', values: [...], aggregate: 250 },
4730
+ * // { key: 'B', values: [...], aggregate: 300 }]
4731
+ * ```
4732
+ */
4733
+ declare function group<T, K extends string | number = string>(data: T[], config: GroupConfig<T, K>): GroupResult<T, K>[];
4734
+ /**
4735
+ * 多级分组
4736
+ *
4737
+ * @example
4738
+ * ```ts
4739
+ * const data = [
4740
+ * { year: 2020, quarter: 'Q1', value: 100 },
4741
+ * { year: 2020, quarter: 'Q2', value: 150 },
4742
+ * { year: 2021, quarter: 'Q1', value: 200 }
4743
+ * ];
4744
+ *
4745
+ * const nested = groupMulti(data, [
4746
+ * d => d.year,
4747
+ * d => d.quarter
4748
+ * ]);
4749
+ * // Map { 2020 => Map { Q1 => [...], Q2 => [...] }, 2021 => Map { Q1 => [...] } }
4750
+ * ```
4751
+ */
4752
+ declare function groupMulti<T>(data: T[], keys: Array<(d: T) => string | number>): Map<unknown, unknown>;
4753
+ /**
4754
+ * 按值排序分组结果
4755
+ */
4756
+ declare function sortGroups<T, K extends string | number>(groups: GroupResult<T, K>[], order?: 'ascending' | 'descending'): GroupResult<T, K>[];
4757
+ /**
4758
+ * 计算滚动统计量
4759
+ *
4760
+ * @example
4761
+ * ```ts
4762
+ * const prices = [100, 102, 98, 103, 105, 101, 99, 104];
4763
+ *
4764
+ * // 5日移动平均
4765
+ * const ma5 = rolling(prices, {
4766
+ * window: 5,
4767
+ * type: 'mean'
4768
+ * });
4769
+ *
4770
+ * // 结果: [undefined, undefined, undefined, undefined, 101.6, 101.8, 101.2, 102.4]
4771
+ * ```
4772
+ */
4773
+ declare function rolling<T>(data: T[], config: RollingConfig & {
4774
+ accessor?: (d: T) => number;
4775
+ }): (number | undefined)[];
4776
+ /**
4777
+ * 生成等间距数组
4778
+ *
4779
+ * @example
4780
+ * ```ts
4781
+ * range(0, 10, 2); // [0, 2, 4, 6, 8]
4782
+ * range(5); // [0, 1, 2, 3, 4]
4783
+ * ```
4784
+ */
4785
+ declare function range(start: number, stop?: number, step?: number): number[];
4786
+ /**
4787
+ * 生成漂亮的刻度值
4788
+ *
4789
+ * @example
4790
+ * ```ts
4791
+ * ticks(0, 100, 5); // [0, 20, 40, 60, 80, 100]
4792
+ * ticks(0.3, 2.7, 5); // [0.5, 1, 1.5, 2, 2.5]
4793
+ * ```
4794
+ */
4795
+ declare function ticks(start: number, stop: number, count: number): number[];
4796
+ /**
4797
+ * 计算漂亮的刻度间隔
4798
+ */
4799
+ declare function tickStep(start: number, stop: number, count: number): number;
4800
+ /**
4801
+ * 转置二维数组
4802
+ *
4803
+ * @example
4804
+ * ```ts
4805
+ * const matrix = [[1, 2, 3], [4, 5, 6]];
4806
+ * transpose(matrix); // [[1, 4], [2, 5], [3, 6]]
4807
+ * ```
4808
+ */
4809
+ declare function transpose<T>(matrix: T[][]): T[][];
4810
+ /**
4811
+ * 合并多个数组
4812
+ *
4813
+ * @example
4814
+ * ```ts
4815
+ * const a = [1, 2];
4816
+ * const b = [3, 4];
4817
+ * const c = [5, 6];
4818
+ * merge([a, b, c]); // [1, 2, 3, 4, 5, 6]
4819
+ * ```
4820
+ */
4821
+ declare function merge<T>(arrays: T[][]): T[];
4822
+ /**
4823
+ * 对数组进行排列
4824
+ *
4825
+ * @example
4826
+ * ```ts
4827
+ * const data = ['c', 'a', 'b'];
4828
+ * const order = permute(data, [1, 2, 0]); // ['a', 'b', 'c']
4829
+ * ```
4830
+ */
4831
+ declare function permute<T>(array: T[], indices: number[]): T[];
4832
+ /**
4833
+ * 打乱数组(Fisher-Yates)
4834
+ *
4835
+ * @example
4836
+ * ```ts
4837
+ * const data = [1, 2, 3, 4, 5];
4838
+ * shuffle(data); // 随机顺序
4839
+ * ```
4840
+ */
4841
+ declare function shuffle<T>(array: T[]): T[];
4842
+ /**
4843
+ * 二分查找插入位置(左侧)
4844
+ *
4845
+ * @example
4846
+ * ```ts
4847
+ * const data = [1, 2, 3, 4, 5];
4848
+ * bisectLeft(data, 3); // 2
4849
+ * ```
4850
+ */
4851
+ declare function bisectLeft<T>(array: T[], x: number, accessor?: (d: T) => number): number;
4852
+ /**
4853
+ * 二分查找插入位置(右侧)
4854
+ */
4855
+ declare function bisectRight<T>(array: T[], x: number, accessor?: (d: T) => number): number;
4856
+ /**
4857
+ * 二分查找最近值的索引
4858
+ */
4859
+ declare function bisectCenter<T>(array: T[], x: number, accessor?: (d: T) => number): number;
4860
+ /**
4861
+ * 找到最近的值
4862
+ *
4863
+ * @example
4864
+ * ```ts
4865
+ * const data = [1, 5, 10, 20];
4866
+ * nearest(data, 7); // 5
4867
+ * nearest(data, 8); // 10
4868
+ * ```
4869
+ */
4870
+ declare function nearest<T>(array: T[], x: number, accessor?: (d: T) => number): T | undefined;
4871
+ /**
4872
+ * 计算累计和
4873
+ *
4874
+ * @example
4875
+ * ```ts
4876
+ * const values = [1, 2, 3, 4, 5];
4877
+ * cumsum(values); // [1, 3, 6, 10, 15]
4878
+ * ```
4879
+ */
4880
+ declare function cumsum<T>(data: T[], accessor?: (d: T) => number): number[];
4881
+ /**
4882
+ * 计算差分
4883
+ *
4884
+ * @example
4885
+ * ```ts
4886
+ * const values = [1, 3, 6, 10, 15];
4887
+ * diff(values); // [2, 3, 4, 5]
4888
+ * ```
4889
+ */
4890
+ declare function diff<T>(data: T[], accessor?: (d: T) => number): number[];
4891
+ /**
4892
+ * 归一化到 [0, 1]
4893
+ *
4894
+ * @example
4895
+ * ```ts
4896
+ * const values = [10, 20, 30, 40, 50];
4897
+ * normalize(values); // [0, 0.25, 0.5, 0.75, 1]
4898
+ * ```
4899
+ */
4900
+ declare function normalize<T>(data: T[], accessor?: (d: T) => number): number[];
4901
+
4902
+ /**
4903
+ * 3D Types - 3D 类型定义
4904
+ */
4905
+
4906
+ /**
4907
+ * 3D 相机配置
4908
+ */
4909
+ interface ThreeDCameraConfig {
4910
+ /** 仰角 (弧度, 0 = 水平, PI/2 = 顶视) */
4911
+ phi?: number;
4912
+ /** 方位角 (弧度) */
4913
+ theta?: number;
4914
+ /** 相机距离 */
4915
+ distance?: number;
4916
+ /** 焦距 (影响透视强度) */
4917
+ focalLength?: number;
4918
+ /** 相机目标点 */
4919
+ target?: Vector3;
4920
+ }
4921
+ /**
4922
+ * 3D 坐标轴配置
4923
+ */
4924
+ interface ThreeDAxesConfig {
4925
+ /** X 轴范围 */
4926
+ xRange?: [number, number];
4927
+ /** Y 轴范围 */
4928
+ yRange?: [number, number];
4929
+ /** Z 轴范围 */
4930
+ zRange?: [number, number];
4931
+ /** 轴线颜色 */
4932
+ axisColor?: string;
4933
+ /** X 轴颜色 */
4934
+ xColor?: string;
4935
+ /** Y 轴颜色 */
4936
+ yColor?: string;
4937
+ /** Z 轴颜色 */
4938
+ zColor?: string;
4939
+ /** 轴线宽度 */
4940
+ axisWidth?: number;
4941
+ /** 是否显示网格 */
4942
+ showGrid?: boolean;
4943
+ /** 网格颜色 */
4944
+ gridColor?: string;
4945
+ /** 单位长度 (像素) */
4946
+ unitSize?: number;
4947
+ }
4948
+ /**
4949
+ * 曲面配置
4950
+ */
4951
+ interface SurfaceConfig {
4952
+ /** U 参数范围 */
4953
+ uRange?: [number, number];
4954
+ /** V 参数范围 */
4955
+ vRange?: [number, number];
4956
+ /** U 方向分辨率 */
4957
+ uResolution?: number;
4958
+ /** V 方向分辨率 */
4959
+ vResolution?: number;
4960
+ /** 填充颜色 */
4961
+ fillColor?: string;
4962
+ /** 边框颜色 */
4963
+ strokeColor?: string;
4964
+ /** 边框宽度 */
4965
+ strokeWidth?: number;
4966
+ /** 是否使用棋盘格 */
4967
+ checkerboard?: boolean;
4968
+ /** 棋盘格颜色1 */
4969
+ checkerColor1?: string;
4970
+ /** 棋盘格颜色2 */
4971
+ checkerColor2?: string;
4972
+ /** 不透明度 */
4973
+ opacity?: number;
4974
+ }
4975
+ /**
4976
+ * 3D 图元配置
4977
+ */
4978
+ interface Primitive3DConfig {
4979
+ /** 填充颜色 */
4980
+ fillColor?: string;
4981
+ /** 边框颜色 */
4982
+ strokeColor?: string;
4983
+ /** 边框宽度 */
4984
+ strokeWidth?: number;
4985
+ /** 不透明度 */
4986
+ opacity?: number;
4987
+ }
4988
+ /**
4989
+ * 球体配置
4990
+ */
4991
+ interface SphereConfig extends Primitive3DConfig {
4992
+ /** 经度分辨率 */
4993
+ longitudeResolution?: number;
4994
+ /** 纬度分辨率 */
4995
+ latitudeResolution?: number;
4996
+ /** 是否使用棋盘格 */
4997
+ checkerboard?: boolean;
4998
+ }
4999
+ /**
5000
+ * 立方体配置
5001
+ */
5002
+ interface CubeConfig extends Primitive3DConfig {
5003
+ /** 面不透明度 */
5004
+ faceOpacity?: number;
5005
+ }
5006
+ /**
5007
+ * 圆柱配置
5008
+ */
5009
+ interface CylinderConfig extends Primitive3DConfig {
5010
+ /** 分辨率 */
5011
+ resolution?: number;
5012
+ }
5013
+ /**
5014
+ * 圆锥配置
5015
+ */
5016
+ interface ConeConfig extends Primitive3DConfig {
5017
+ /** 分辨率 */
5018
+ resolution?: number;
5019
+ }
5020
+ /**
5021
+ * 投影结果
5022
+ */
5023
+ interface ProjectionResult {
5024
+ /** 投影后的 2D 点 */
5025
+ point: Vector2;
5026
+ /** 深度值 (用于排序) */
5027
+ depth: number;
5028
+ /** 是否在视野内 */
5029
+ visible: boolean;
5030
+ }
5031
+ /**
5032
+ * 3D 多边形面
5033
+ */
5034
+ interface Face3D {
5035
+ /** 顶点索引 */
5036
+ vertices: number[];
5037
+ /** 填充颜色 */
5038
+ fillColor: string;
5039
+ /** 边框颜色 */
5040
+ strokeColor: string;
5041
+ /** 深度值 (用于排序) */
5042
+ depth: number;
5043
+ }
5044
+
5045
+ /**
5046
+ * ThreeDCamera - 3D 相机
5047
+ *
5048
+ * 处理 3D 到 2D 的投影变换
5049
+ */
5050
+
5051
+ /**
5052
+ * 3D 相机类
5053
+ *
5054
+ * 使用球坐标系定位相机,支持透视投影
5055
+ */
5056
+ declare class ThreeDCamera {
5057
+ /** 仰角 (弧度) */
5058
+ phi: number;
5059
+ /** 方位角 (弧度) */
5060
+ theta: number;
5061
+ /** 相机距离 */
5062
+ distance: number;
5063
+ /** 焦距 */
5064
+ focalLength: number;
5065
+ /** 相机目标点 */
5066
+ target: Vector3;
5067
+ /**
5068
+ * 创建 3D 相机
5069
+ */
5070
+ constructor(config?: ThreeDCameraConfig);
5071
+ /**
5072
+ * 设置相机位置
5073
+ */
5074
+ setPosition(phi: number, theta: number, distance?: number): void;
5075
+ /**
5076
+ * 绕目标点旋转
5077
+ */
5078
+ orbitAround(dphi: number, dtheta: number): void;
5079
+ /**
5080
+ * 获取相机位置 (世界坐标)
5081
+ */
5082
+ getPosition(): Vector3;
5083
+ /**
5084
+ * 投影 3D 点到 2D
5085
+ *
5086
+ * 使用透视投影
5087
+ */
5088
+ project(point: Vector3): Vector2;
5089
+ /**
5090
+ * 获取投影结果 (包含深度信息)
5091
+ */
5092
+ projectWithDepth(point: Vector3): ProjectionResult;
5093
+ /**
5094
+ * 获取深度值 (用于排序)
5095
+ */
5096
+ getDepth(point: Vector3): number;
5097
+ /**
5098
+ * 批量投影点
5099
+ */
5100
+ projectPoints(points: Vector3[]): Vector2[];
5101
+ /**
5102
+ * 克隆相机
5103
+ */
5104
+ clone(): ThreeDCamera;
5105
+ }
5106
+ /**
5107
+ * 创建 3D 相机
5108
+ */
5109
+ declare function createThreeDCamera(config?: ThreeDCameraConfig): ThreeDCamera;
5110
+
5111
+ /**
5112
+ * ThreeDAxes - 3D 坐标轴
5113
+ *
5114
+ * 绘制 3D 坐标系和网格
5115
+ */
5116
+
5117
+ /**
5118
+ * 3D 坐标轴类
5119
+ */
5120
+ declare class ThreeDAxes {
5121
+ protected _xRange: [number, number];
5122
+ protected _yRange: [number, number];
5123
+ protected _zRange: [number, number];
5124
+ protected _xColor: string;
5125
+ protected _yColor: string;
5126
+ protected _zColor: string;
5127
+ protected _axisWidth: number;
5128
+ protected _showGrid: boolean;
5129
+ protected _gridColor: string;
5130
+ protected _unitSize: number;
5131
+ /**
5132
+ * 创建 3D 坐标轴
5133
+ */
5134
+ constructor(config?: ThreeDAxesConfig);
5135
+ /**
5136
+ * 转换为 Diagram
5137
+ */
5138
+ toDiagram(camera: ThreeDCamera, centerX: number, centerY: number): Diagram;
5139
+ /**
5140
+ * 绘制网格
5141
+ */
5142
+ protected drawGrid(camera: ThreeDCamera, centerX: number, centerY: number): Diagram[];
5143
+ /**
5144
+ * 将世界坐标转换为屏幕坐标
5145
+ */
5146
+ worldToScreen(point: Vector3, camera: ThreeDCamera, centerX: number, centerY: number): [number, number];
5147
+ /**
5148
+ * 获取单位大小
5149
+ */
5150
+ get unitSize(): number;
5151
+ }
5152
+ /**
5153
+ * 创建 3D 坐标轴
5154
+ */
5155
+ declare function createThreeDAxes(config?: ThreeDAxesConfig): ThreeDAxes;
5156
+
5157
+ /**
5158
+ * 3D Primitives - 3D 基础图元
5159
+ *
5160
+ * 提供 3D 图形的创建函数
5161
+ */
5162
+
5163
+ /**
5164
+ * 3D 点
5165
+ */
5166
+ declare function dot3D(position: Vector3, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: Primitive3DConfig & {
5167
+ radius?: number;
5168
+ }): Diagram;
5169
+ /**
5170
+ * 3D 线段
5171
+ */
5172
+ declare function line3D(from: Vector3, to: Vector3, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: Primitive3DConfig): Diagram;
5173
+ /**
5174
+ * 3D 箭头
5175
+ */
5176
+ declare function arrow3D(from: Vector3, to: Vector3, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: Primitive3DConfig & {
5177
+ headSize?: number;
5178
+ }): Diagram;
5179
+ /**
5180
+ * 3D 立方体
5181
+ */
5182
+ declare function cube3D(sideLength: number, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: CubeConfig): Diagram;
5183
+ /**
5184
+ * 3D 球体 (线框)
5185
+ */
5186
+ declare function sphere3D(radius: number, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: SphereConfig): Diagram;
5187
+ /**
5188
+ * 3D 圆柱体
5189
+ */
5190
+ declare function cylinder3D(radiusVal: number, height: number, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: CylinderConfig): Diagram;
5191
+ /**
5192
+ * 3D 圆锥体
5193
+ */
5194
+ declare function cone3D(baseRadius: number, height: number, camera: ThreeDCamera, centerX: number, centerY: number, scale: number, config?: ConeConfig): Diagram;
5195
+
5196
+ /**
5197
+ * Diagramatics Compatibility Layer
5198
+ *
5199
+ * 提供与 Diagramatics (https://diagramatics.photon-ray.xyz/) 兼容的 API 别名
5200
+ *
5201
+ * Diagramatics usage guide 中使用的标识符:
5202
+ * - square, circle, V2 → Locusing 已有同名
5203
+ * - diagram_combine → Locusing 的 combine
5204
+ * - draw_to_svg → Locusing 的 renderToSVG / toSVGString
5205
+ * - Interactive → Locusing 已有同名
5206
+ */
5207
+
5208
+ /**
5209
+ * diagram_combine - Diagramatics 风格的组合函数
5210
+ *
5211
+ * 等价于 Locusing 的 combine()
5212
+ *
5213
+ * @example
5214
+ * ```typescript
5215
+ * const combined = diagram_combine(circle(1), square(0.5));
5216
+ * ```
5217
+ */
5218
+ declare const diagram_combine: typeof combine;
5219
+ /**
5220
+ * draw_to_svg - Diagramatics 风格的渲染函数
5221
+ *
5222
+ * 将 Diagram 渲染到 SVG 元素
5223
+ *
5224
+ * @param diagram - 要渲染的 Diagram
5225
+ * @param svg - 目标 SVG 元素
5226
+ * @param options - 渲染选项
5227
+ *
5228
+ * @example
5229
+ * ```typescript
5230
+ * const svg = document.querySelector('svg');
5231
+ * draw_to_svg(myDiagram, svg, { width: 800, height: 600 });
5232
+ * ```
5233
+ */
5234
+ declare function draw_to_svg(diagram: Diagram, svg: SVGSVGElement, options?: RenderOptions): void;
5235
+ /**
5236
+ * draw_to_svg_string - 将 Diagram 渲染为 SVG 字符串
5237
+ *
5238
+ * @param diagram - 要渲染的 Diagram
5239
+ * @param options - 渲染选项
5240
+ * @returns SVG 字符串
5241
+ */
5242
+ declare function draw_to_svg_string(diagram: Diagram, options?: RenderOptions): string;
5243
+ /**
5244
+ * Diagramatics 中的 empty() 函数
5245
+ * 创建一个空的组合
5246
+ */
5247
+ declare function empty(): Diagram;
5248
+
5249
+ /**
5250
+ * Manim Compatibility Layer
5251
+ *
5252
+ * 提供与 Manim Community (https://docs.manim.community/) 兼容的 API 别名
5253
+ *
5254
+ * 主要映射:
5255
+ * - Mobject → Diagram (薄包装)
5256
+ * - VMobject → Diagram
5257
+ * - VGroup → group/combine
5258
+ * - MathTex → tex
5259
+ * - rate_functions → easing
5260
+ */
5261
+
5262
+ /**
5263
+ * Mobject - Manim 的基础对象类型
5264
+ *
5265
+ * 在 Locusing 中,Diagram 是基础对象类型
5266
+ * Mobject 作为 Diagram 的类型别名提供
5267
+ */
5268
+ type Mobject = Diagram;
5269
+ /**
5270
+ * VMobject - Manim 的矢量对象类型
5271
+ *
5272
+ * 在 Locusing 中等价于 Diagram
5273
+ */
5274
+ type VMobject = Diagram;
5275
+ /**
5276
+ * VGroup - Manim 的矢量对象组
5277
+ *
5278
+ * 等价于 Locusing 的 group/combine
5279
+ *
5280
+ * @example
5281
+ * ```typescript
5282
+ * const vgroup = VGroup(circle(1), square(0.5));
5283
+ * ```
5284
+ */
5285
+ declare function VGroup(...diagrams: Diagram[]): Diagram;
5286
+ /**
5287
+ * Group - Manim 的对象组
5288
+ *
5289
+ * 等价于 VGroup
5290
+ */
5291
+ declare const Group: typeof VGroup;
5292
+ /**
5293
+ * MathTex - Manim 的数学 LaTeX 渲染
5294
+ *
5295
+ * 等价于 Locusing 的 tex()
5296
+ *
5297
+ * @param latex - LaTeX 字符串
5298
+ * @param options - 选项
5299
+ *
5300
+ * @example
5301
+ * ```typescript
5302
+ * const formula = MathTex('E = mc^2');
5303
+ * ```
5304
+ */
5305
+ declare function MathTex(latex: string, options?: {
5306
+ fontSize?: number;
5307
+ }): Diagram;
5308
+ /**
5309
+ * Tex - Manim 的 LaTeX 渲染(与 MathTex 类似)
5310
+ */
5311
+ declare const Tex: typeof MathTex;
5312
+ /**
5313
+ * Manim rate_functions 到 Locusing easing 的映射
5314
+ *
5315
+ * Manim 的 rate_functions 模块提供了多种缓动函数
5316
+ * 这里提供与 Manim 兼容的命名
5317
+ */
5318
+ declare const rate_functions: {
5319
+ /**
5320
+ * linear - 线性(无缓动)
5321
+ */
5322
+ linear: (t: number) => number;
5323
+ /**
5324
+ * smooth - 平滑(等价于 ease_in_out_sine)
5325
+ */
5326
+ smooth: (t: number) => number;
5327
+ /**
5328
+ * rush_into - 快速进入(等价于 ease_in)
5329
+ */
5330
+ rush_into: (t: number) => number;
5331
+ /**
5332
+ * rush_from - 快速离开(等价于 ease_out)
5333
+ */
5334
+ rush_from: (t: number) => number;
5335
+ /**
5336
+ * slow_into - 缓慢进入
5337
+ */
5338
+ slow_into: (t: number) => number;
5339
+ /**
5340
+ * double_smooth - 双重平滑(使用 easeInOutCubic 近似)
5341
+ */
5342
+ double_smooth: (t: number) => number;
5343
+ /**
5344
+ * there_and_back - 往返
5345
+ */
5346
+ there_and_back: (t: number) => number;
5347
+ /**
5348
+ * there_and_back_with_pause - 往返带暂停
5349
+ */
5350
+ there_and_back_with_pause: (t: number, pauseRatio?: number) => number;
5351
+ /**
5352
+ * running_start - 带助跑的开始
5353
+ */
5354
+ running_start: (t: number, pullFactor?: number) => number;
5355
+ /**
5356
+ * not_quite_there - 未完全到达
5357
+ */
5358
+ not_quite_there: (t: number, proportion?: number) => number;
5359
+ /**
5360
+ * wiggle - 摆动
5361
+ */
5362
+ wiggle: (t: number, wiggles?: number) => number;
5363
+ /**
5364
+ * squish_rate_func - 压缩速率函数到指定区间
5365
+ */
5366
+ squish_rate_func: (func: (t: number) => number, a?: number, b?: number) => (t: number) => number;
5367
+ /**
5368
+ * lingering - 徘徊(慢结束)
5369
+ */
5370
+ lingering: (t: number) => number;
5371
+ /**
5372
+ * exponential_decay - 指数衰减
5373
+ */
5374
+ exponential_decay: (t: number, half_life?: number) => number;
5375
+ ease_in_sine: (t: number) => number;
5376
+ ease_out_sine: (t: number) => number;
5377
+ ease_in_out_sine: (t: number) => number;
5378
+ ease_in_quad: (t: number) => number;
5379
+ ease_out_quad: (t: number) => number;
5380
+ ease_in_out_quad: (t: number) => number;
5381
+ ease_in_cubic: (t: number) => number;
5382
+ ease_out_cubic: (t: number) => number;
5383
+ ease_in_out_cubic: (t: number) => number;
5384
+ ease_in_expo: (t: number) => number;
5385
+ ease_out_expo: (t: number) => number;
5386
+ ease_in_out_expo: (t: number) => number;
5387
+ ease_in_back: (t: number) => number;
5388
+ ease_out_back: (t: number) => number;
5389
+ ease_in_out_back: (t: number) => number;
5390
+ ease_in_elastic: (t: number) => number;
5391
+ ease_out_elastic: (t: number) => number;
5392
+ ease_out_bounce: (t: number) => number;
5393
+ ease_in_bounce: (t: number) => number;
5394
+ };
5395
+
5396
+ /**
5397
+ * @locusing/physics - 类型定义
5398
+ *
5399
+ * 2D 物理系统的类型定义
5400
+ */
5401
+
5402
+ /** Matter.js Body 类型别名 */
5403
+ type MatterBody = Matter.Body;
5404
+ /** Matter.js Constraint 类型别名 */
5405
+ type MatterConstraint = Matter.Constraint;
5406
+ /** 刚体形状类型 */
5407
+ type BodyShapeType = 'rectangle' | 'circle' | 'polygon';
5408
+ /** 刚体配置基础 */
5409
+ interface BodyOptionsBase {
5410
+ /** 位置 */
5411
+ position?: Vector2;
5412
+ /** 旋转角度(弧度) */
5413
+ angle?: number;
5414
+ /** 是否静态(不受力影响) */
5415
+ isStatic?: boolean;
5416
+ /** 密度 */
5417
+ density?: number;
5418
+ /** 摩擦系数 */
5419
+ friction?: number;
5420
+ /** 弹性系数(反弹) */
5421
+ restitution?: number;
5422
+ /** 空气阻力 */
5423
+ frictionAir?: number;
5424
+ /** 标签(用于识别) */
5425
+ label?: string;
5426
+ }
5427
+ /** 矩形刚体配置 */
5428
+ interface RectBodyOptions extends BodyOptionsBase {
5429
+ type: 'rectangle';
5430
+ width: number;
5431
+ height: number;
5432
+ }
5433
+ /** 圆形刚体配置 */
5434
+ interface CircleBodyOptions extends BodyOptionsBase {
5435
+ type: 'circle';
5436
+ radius: number;
5437
+ }
5438
+ /** 多边形刚体配置 */
5439
+ interface PolygonBodyOptions extends BodyOptionsBase {
5440
+ type: 'polygon';
5441
+ vertices: Vector2[];
5442
+ }
5443
+ /** 刚体配置联合类型 */
5444
+ type BodyOptions = RectBodyOptions | CircleBodyOptions | PolygonBodyOptions;
5445
+ /** 约束类型 */
5446
+ type ConstraintType = 'distance' | 'point' | 'spring';
5447
+ /** 约束配置基础 */
5448
+ interface ConstraintOptionsBase {
5449
+ /** 刚度 */
5450
+ stiffness?: number;
5451
+ /** 阻尼 */
5452
+ damping?: number;
5453
+ /** 标签 */
5454
+ label?: string;
5455
+ }
5456
+ /** 距离约束配置 */
5457
+ interface DistanceConstraintOptions extends ConstraintOptionsBase {
5458
+ type: 'distance';
5459
+ /** 固定长度(不设置则使用当前距离) */
5460
+ length?: number;
5461
+ /** 连接点 A 的偏移 */
5462
+ pointA?: Vector2;
5463
+ /** 连接点 B 的偏移 */
5464
+ pointB?: Vector2;
5465
+ }
5466
+ /** 点约束配置(固定到世界坐标点) */
5467
+ interface PointConstraintOptions extends ConstraintOptionsBase {
5468
+ type: 'point';
5469
+ /** 世界坐标点 */
5470
+ point: Vector2;
5471
+ /** 连接点偏移 */
5472
+ pointA?: Vector2;
5473
+ }
5474
+ /** 弹簧约束配置 */
5475
+ interface SpringConstraintOptions extends ConstraintOptionsBase {
5476
+ type: 'spring';
5477
+ /** 静止长度 */
5478
+ length?: number;
5479
+ /** 连接点 A 的偏移 */
5480
+ pointA?: Vector2;
5481
+ /** 连接点 B 的偏移 */
5482
+ pointB?: Vector2;
5483
+ }
5484
+ /** 约束配置联合类型 */
5485
+ type ConstraintOptions = DistanceConstraintOptions | PointConstraintOptions | SpringConstraintOptions;
5486
+ /** 物理世界配置 */
5487
+ interface WorldConfig {
5488
+ /** 重力(默认 [0, 1],向下) */
5489
+ gravity?: Vector2;
5490
+ /** 时间步长(默认 1/60) */
5491
+ timeStep?: number;
5492
+ /** 速度迭代次数 */
5493
+ velocityIterations?: number;
5494
+ /** 位置迭代次数 */
5495
+ positionIterations?: number;
5496
+ }
5497
+ /** 物理体包装 */
5498
+ interface PhysicsBody {
5499
+ /** 内部 Matter.js Body 引用 */
5500
+ readonly _body: MatterBody;
5501
+ /** 唯一 ID */
5502
+ readonly id: number;
5503
+ /** 标签 */
5504
+ readonly label: string;
5505
+ /** 获取当前位置 */
5506
+ getPosition(): Vector2;
5507
+ /** 获取当前角度 */
5508
+ getAngle(): number;
5509
+ /** 获取当前速度 */
5510
+ getVelocity(): Vector2;
5511
+ /** 获取当前角速度 */
5512
+ getAngularVelocity(): number;
5513
+ /** 设置位置 */
5514
+ setPosition(position: Vector2): void;
5515
+ /** 设置角度 */
5516
+ setAngle(angle: number): void;
5517
+ /** 设置速度 */
5518
+ setVelocity(velocity: Vector2): void;
5519
+ /** 设置角速度 */
5520
+ setAngularVelocity(velocity: number): void;
5521
+ /** 施加力 */
5522
+ applyForce(force: Vector2, point?: Vector2): void;
5523
+ /** 施加冲量 */
5524
+ applyImpulse(impulse: Vector2, point?: Vector2): void;
5525
+ /** 是否静态 */
5526
+ isStatic(): boolean;
5527
+ /** 设置静态 */
5528
+ setStatic(isStatic: boolean): void;
5529
+ }
5530
+ /** 物理约束包装 */
5531
+ interface PhysicsConstraint {
5532
+ /** 内部 Matter.js Constraint 引用 */
5533
+ readonly _constraint: MatterConstraint;
5534
+ /** 唯一 ID */
5535
+ readonly id: number;
5536
+ /** 标签 */
5537
+ readonly label: string;
5538
+ /** 设置刚度 */
5539
+ setStiffness(stiffness: number): void;
5540
+ /** 设置阻尼 */
5541
+ setDamping(damping: number): void;
5542
+ /** 设置长度 */
5543
+ setLength(length: number): void;
5544
+ }
5545
+ /** Diagram 与物理体的绑定 */
5546
+ interface PhysicsBinding {
5547
+ /** 物理体 */
5548
+ body: PhysicsBody;
5549
+ /** 绑定的 Diagram */
5550
+ diagram: Diagram;
5551
+ /** 位置偏移 */
5552
+ offset?: Vector2;
5553
+ /** 是否同步旋转 */
5554
+ syncRotation?: boolean;
5555
+ }
5556
+ /** 物理状态 */
5557
+ interface PhysicsState {
5558
+ /** 位置 */
5559
+ position: Vector2;
5560
+ /** 角度 */
5561
+ angle: number;
5562
+ /** 速度 */
5563
+ velocity: Vector2;
5564
+ /** 角速度 */
5565
+ angularVelocity: number;
5566
+ }
5567
+ /** 碰撞事件 */
5568
+ interface CollisionEvent {
5569
+ /** 碰撞体 A */
5570
+ bodyA: PhysicsBody;
5571
+ /** 碰撞体 B */
5572
+ bodyB: PhysicsBody;
5573
+ /** 碰撞点 */
5574
+ contacts: Vector2[];
5575
+ }
5576
+ /** 物理事件监听器 */
5577
+ interface PhysicsEventListeners {
5578
+ /** 碰撞开始 */
5579
+ onCollisionStart?: (event: CollisionEvent) => void;
5580
+ /** 碰撞结束 */
5581
+ onCollisionEnd?: (event: CollisionEvent) => void;
5582
+ /** 碰撞激活中 */
5583
+ onCollisionActive?: (event: CollisionEvent) => void;
5584
+ /** 每帧更新后 */
5585
+ onAfterUpdate?: (time: number) => void;
5586
+ }
5587
+
5588
+ /**
5589
+ * @locusing/physics - Physics2DWorld
5590
+ *
5591
+ * 2D 物理世界管理器,封装 Matter.js
5592
+ */
5593
+
5594
+ /**
5595
+ * 2D 物理世界
5596
+ *
5597
+ * 封装 Matter.js,提供与 Locusing Diagram 的集成
5598
+ *
5599
+ * @example
5600
+ * ```typescript
5601
+ * const world = new Physics2DWorld({ gravity: [0, 9.8] });
5602
+ *
5603
+ * // 创建刚体
5604
+ * const ball = world.createBody({
5605
+ * type: 'circle',
5606
+ * radius: 0.5,
5607
+ * position: [0, 3]
5608
+ * });
5609
+ *
5610
+ * // 绑定到 Diagram
5611
+ * const ballDiagram = circle(0.5);
5612
+ * world.bind(ball, ballDiagram);
5613
+ *
5614
+ * // 在场景中使用
5615
+ * scene.addUpdater(() => {
5616
+ * world.step();
5617
+ * return world.syncDiagrams();
5618
+ * });
5619
+ * ```
5620
+ */
5621
+ declare class Physics2DWorld {
5622
+ private engine;
5623
+ private world;
5624
+ private bodies;
5625
+ private constraints;
5626
+ private bindings;
5627
+ private listeners;
5628
+ private timeStep;
5629
+ constructor(config?: WorldConfig);
5630
+ /**
5631
+ * 创建刚体
5632
+ */
5633
+ createBody(options: BodyOptions): PhysicsBody;
5634
+ /**
5635
+ * 创建矩形刚体(快捷方法)
5636
+ */
5637
+ createRect(width: number, height: number, options?: Omit<BodyOptions, 'type' | 'width' | 'height'>): PhysicsBody;
5638
+ /**
5639
+ * 创建圆形刚体(快捷方法)
5640
+ */
5641
+ createCircle(radius: number, options?: Omit<BodyOptions, 'type' | 'radius'>): PhysicsBody;
5642
+ /**
5643
+ * 创建多边形刚体(快捷方法)
5644
+ */
5645
+ createPolygon(vertices: Vector2[], options?: Omit<BodyOptions, 'type' | 'vertices'>): PhysicsBody;
5646
+ /**
5647
+ * 移除刚体
5648
+ */
5649
+ removeBody(body: PhysicsBody): void;
5650
+ /**
5651
+ * 获取所有刚体
5652
+ */
5653
+ getBodies(): PhysicsBody[];
5654
+ /**
5655
+ * 创建约束
5656
+ */
5657
+ createConstraint(bodyA: PhysicsBody, bodyB: PhysicsBody | null, options: ConstraintOptions): PhysicsConstraint;
5658
+ /**
5659
+ * 创建距离约束(快捷方法)
5660
+ */
5661
+ createDistanceConstraint(bodyA: PhysicsBody, bodyB: PhysicsBody, options?: Partial<Omit<ConstraintOptions, 'type'>>): PhysicsConstraint;
5662
+ /**
5663
+ * 创建弹簧约束(快捷方法)
5664
+ */
5665
+ createSpring(bodyA: PhysicsBody, bodyB: PhysicsBody, options?: Partial<Omit<SpringConstraintOptions, 'type'>>): PhysicsConstraint;
5666
+ /**
5667
+ * 创建固定点约束(快捷方法)
5668
+ */
5669
+ createPinConstraint(body: PhysicsBody, point: Vector2, options?: Partial<Omit<ConstraintOptions, 'type' | 'point'>>): PhysicsConstraint;
5670
+ /**
5671
+ * 移除约束
5672
+ */
5673
+ removeConstraint(constraint: PhysicsConstraint): void;
5674
+ /**
5675
+ * 绑定物理体到 Diagram
5676
+ */
5677
+ bind(body: PhysicsBody, diagram: Diagram, options?: {
5678
+ offset?: Vector2;
5679
+ syncRotation?: boolean;
5680
+ }): PhysicsBinding;
5681
+ /**
5682
+ * 解除绑定
5683
+ */
5684
+ unbind(body: PhysicsBody): void;
5685
+ /**
5686
+ * 获取绑定的 Diagram
5687
+ */
5688
+ getBoundDiagram(body: PhysicsBody): Diagram | undefined;
5689
+ /**
5690
+ * 同步所有绑定的 Diagram
5691
+ * @returns 更新后的 Diagram 数组
5692
+ */
5693
+ syncDiagrams(): Diagram[];
5694
+ /**
5695
+ * 获取物理体状态
5696
+ */
5697
+ getState(body: PhysicsBody): PhysicsState;
5698
+ /**
5699
+ * 步进模拟
5700
+ */
5701
+ step(delta?: number): void;
5702
+ /**
5703
+ * 设置重力
5704
+ */
5705
+ setGravity(gravity: Vector2): void;
5706
+ /**
5707
+ * 获取重力
5708
+ */
5709
+ getGravity(): Vector2;
5710
+ /**
5711
+ * 清空物理世界
5712
+ */
5713
+ clear(): void;
5714
+ /**
5715
+ * 设置事件监听器
5716
+ */
5717
+ on(listeners: PhysicsEventListeners): void;
5718
+ private setupCollisionEvents;
5719
+ /**
5720
+ * 创建鼠标约束(用于拖拽)
5721
+ * @returns 控制鼠标约束的函数
5722
+ */
5723
+ createMouseConstraint(): {
5724
+ startDrag: (body: PhysicsBody, worldPoint: Vector2) => void;
5725
+ moveTo: (worldPoint: Vector2) => void;
5726
+ endDrag: () => void;
5727
+ getCurrentBody: () => PhysicsBody | null;
5728
+ };
5729
+ /**
5730
+ * 检测点击位置的刚体
5731
+ */
5732
+ queryPoint(point: Vector2): PhysicsBody | null;
5733
+ }
5734
+ /**
5735
+ * 创建物理世界(工厂函数)
5736
+ */
5737
+ declare function createPhysicsWorld(config?: WorldConfig): Physics2DWorld;
5738
+
5739
+ /**
5740
+ * @locusing/physics - 预设场景
5741
+ *
5742
+ * 提供常用物理场景的快速创建
5743
+ */
5744
+
5745
+ /** 单摆配置 */
5746
+ interface PendulumConfig {
5747
+ /** 摆长 */
5748
+ length?: number;
5749
+ /** 摆球半径 */
5750
+ ballRadius?: number;
5751
+ /** 初始角度(弧度) */
5752
+ initialAngle?: number;
5753
+ /** 固定点位置 */
5754
+ pivot?: Vector2;
5755
+ }
5756
+ /** 弹簧配置 */
5757
+ interface SpringConfig {
5758
+ /** 弹簧静止长度 */
5759
+ length?: number;
5760
+ /** 质量块大小 */
5761
+ massSize?: number;
5762
+ /** 弹簧刚度 */
5763
+ stiffness?: number;
5764
+ /** 阻尼 */
5765
+ damping?: number;
5766
+ /** 固定点位置 */
5767
+ anchor?: Vector2;
5768
+ /** 是否水平(默认垂直) */
5769
+ horizontal?: boolean;
5770
+ }
5771
+ /** 碰撞场景配置 */
5772
+ interface CollisionConfig {
5773
+ /** 地面 Y 坐标 */
5774
+ groundY?: number;
5775
+ /** 地面宽度 */
5776
+ groundWidth?: number;
5777
+ /** 墙壁(左右边界) */
5778
+ walls?: {
5779
+ left?: number;
5780
+ right?: number;
5781
+ height?: number;
5782
+ };
5783
+ }
5784
+ /** 多体系统配置 */
5785
+ interface MultiBodyConfig extends CollisionConfig {
5786
+ /** 球的数量 */
5787
+ count?: number;
5788
+ /** 球的半径 */
5789
+ radius?: number;
5790
+ /** 初始区域 */
5791
+ spawnArea?: {
5792
+ x: number;
5793
+ y: number;
5794
+ width: number;
5795
+ height: number;
5796
+ };
5797
+ }
5798
+ /**
5799
+ * 创建单摆场景
5800
+ */
5801
+ declare function createPendulum(config?: PendulumConfig, worldConfig?: WorldConfig): {
5802
+ world: Physics2DWorld;
5803
+ ball: PhysicsBody;
5804
+ pivot: Vector2;
5805
+ };
5806
+ /**
5807
+ * 创建弹簧振子场景
5808
+ */
5809
+ declare function createSpringMass(config?: SpringConfig, worldConfig?: WorldConfig): {
5810
+ world: Physics2DWorld;
5811
+ mass: PhysicsBody;
5812
+ anchor: Vector2;
5813
+ };
5814
+ /**
5815
+ * 创建带边界的碰撞场景
5816
+ */
5817
+ declare function createCollisionScene(config?: CollisionConfig, worldConfig?: WorldConfig): {
5818
+ world: Physics2DWorld;
5819
+ ground: PhysicsBody;
5820
+ walls: PhysicsBody[];
5821
+ };
5822
+ /**
5823
+ * 创建多体碰撞场景
5824
+ */
5825
+ declare function createMultiBodyScene(config?: MultiBodyConfig, worldConfig?: WorldConfig): {
5826
+ world: Physics2DWorld;
5827
+ bodies: PhysicsBody[];
5828
+ ground: PhysicsBody;
5829
+ walls: PhysicsBody[];
5830
+ };
5831
+ /**
5832
+ * 创建牛顿摆场景
5833
+ */
5834
+ declare function createNewtonsCradle(config?: {
5835
+ ballCount?: number;
5836
+ ballRadius?: number;
5837
+ stringLength?: number;
5838
+ spacing?: number;
5839
+ pivot?: Vector2;
5840
+ }, worldConfig?: WorldConfig): {
5841
+ world: Physics2DWorld;
5842
+ balls: PhysicsBody[];
5843
+ pivots: Vector2[];
5844
+ };
5845
+ /**
5846
+ * 创建多米诺骨牌场景
5847
+ */
5848
+ declare function createDominoes(config?: {
5849
+ count?: number;
5850
+ spacing?: number;
5851
+ width?: number;
5852
+ height?: number;
5853
+ startX?: number;
5854
+ groundY?: number;
5855
+ }, worldConfig?: WorldConfig): {
5856
+ world: Physics2DWorld;
5857
+ dominoes: PhysicsBody[];
5858
+ ground: PhysicsBody;
5859
+ trigger: PhysicsBody;
5860
+ };
5861
+
5862
+ export { AddTextLetterByLetter, type Animation, type AnimationConfig, AnimationGroup, type AnimationGroupOptions, type AnimationOptions, type AnimationStatus, type AnimationTokens, ApplyMethod, ApplyWave, type ApplyWaveOptions, type ArcConfig, type ArcShape, type AreaConfig, type AreaResult, Axes, type AxesConfig, type AxisColors, type BackgroundColors, type BandScale, type BandScaleConfig, type BaseShape, type Bin, type BinConfig, Blink, type BodyOptions, type BodyOptionsBase, type BodyShapeType, type ButtonConfig, Camera, type CameraAnimationOptions$1 as CameraAnimationOptions, type CameraAnimationState, CameraAutoZoom, type CameraConfig, CameraMove, CameraReset, CameraSetFrame, CameraZoom, type CircleBodyOptions, type CircleShape, Circumscribe, type CircumscribeOptions, ClockwiseTransform, type CollisionConfig, type CollisionEvent, type ColorName, ColorScales, type ColorScheme, type ColorTokens, Colors, type ConeConfig, type ConstraintOptions, type ConstraintOptionsBase, type ConstraintType, type ContinuousScale, type ContinuousScaleConfig, CounterclockwiseTransform, Create, type CreateOptions, type CubeConfig, type CurveType, CyclicReplace, type CylinderConfig, DEGREES, DL, DOWN, DR, type DagreAlign, type DagreEdgeRouting, type DagreLayoutConfig, type DagreLayoutResult, type DagreRankDir, type DagreRanker, type DashPatterns, type DataPoint, type DeepPartial, DiGraph, Diagram, Dir, type DistanceConstraintOptions, DrawBorderThenFill, type DurationTokens, type EasingFunction, type EasingTokens, type EdgeConfig, type EdgeRoute, type EllipseShape, type Extent, type Face3D, FadeIn, FadeInFrom, FadeInFromDown, FadeInFromLeft, FadeInFromRight, FadeInFromUp, type FadeOptions, FadeOut, FadeOutTo, FadeToColor, FadeTransform, Flash, type FlashOptions, FocusOn, type FocusOnOptions, type FontFamilyTokens, type FontSizeTokens, type FontWeightTokens, type Frame, type FrameConfig, Graph, type GraphConfig, Group, type GroupConfig, type GroupResult, type GroupShape, GrowFromCenter, GrowFromEdge, GrowFromPoint, type HSL, Homotopy, IDENTITY, Indicate, type IndicateOptions, Interactive, type InteractiveOptions, LEFT, LaggedStart, LaggedStartMap, type LayoutFunction, type LayoutTokens, type LayoutType, type LineConfig, type LineShape, type LocatorConfig, type LocatorOptions, ManimColor, MathTex, type Matrix3, type MatrixConfig, MatrixDisplay, type Mobject, Morphing, MoveAlongPath, type MoveOptions, MoveTo, MoveToTarget, MovingCamera, type MovingCameraConfig, MovingCameraScene, type MovingCameraSceneConfig, type MultiBodyConfig, NumberLine, NumberPlane, ORIGIN, type OrdinalScale, PI, type PathCommand, type PathShape, type PendulumConfig, PhaseFlow, type PhaseFlowOptions, Physics2DWorld, type PhysicsBinding, type PhysicsBody, type PhysicsConstraint, type PhysicsEventListeners, type PhysicsState, type PieConfig, type PieData, type Point, type PointConstraintOptions, type PointScale, PolarAxes, type PolygonBodyOptions, type PolygonShape, type PolylineShape, type Primitive3DConfig, type ProjectionResult, type RGB, RIGHT, type RectBodyOptions, type RectShape, RemoveTextLetterByLetter, type RenderOptions, ReplacementTransform, type RollingConfig, Rotate, type RotateOptions, Rotating, type RoughRenderOptions, type Scale, type ScaleConfig, ScaleInPlace, type ScaleOptions, Scene, type SceneConfig, type SemanticColors, type Shape, type ShapeType, Shift, ShowPassingFlash, ShrinkToCenter, type SliderConfig, type SliderOptions, type SpacingTokens, type SphereConfig, SpinInFromNothing, SpiralIn, type SpiralInOptions, type SpringConfig, type SpringConstraintOptions, type StackConfig, type StackData, type StrokeTokens, type StrokeWidthTokens, type Style, Succession, type SurfaceConfig, Swap, type SwapOptions, TAU, Table, type TableConfig, Tex, type TexShape, type TextAnimationOptions, type TextColors, type TextShape, type TextStyle, type Theme, type ThemeName, type ThemeOverrides, type ThemeStyles, type ThemeTokens, ThreeB1BColors, ThreeDAxes, type ThreeDAxesConfig, ThreeDCamera, type ThreeDCameraConfig, Timeline, type TimelineOptions, Transform, TransformFromCopy, TransformMatchingShapes, TransformMatchingTex, type TransformMatchingTexOptions, type TransformOptions, Typewriter, type TypewriterOptions, type TypographyTokens, UL, UP, UR, Uncreate, Unwrite, UpdateFromAlphaFunc, UpdateFromFunc, type UpdaterConfig, type UpdaterFunction, V2, V3, VGroup, type VMobject, ValueTracker, type Vector2, type Vector3, type VertexConfig, Wait, Wiggle, type WiggleOptions, type WorldConfig, Write, add, altitude, angle, angleBetween, angleBisector, angleMarker, annularSector, annulus, applyMatrix, applyThemeOverrides, arc, arcBetweenPoints, arcCentroid, arcPoints, areaPoints, arrow, arrow3D, axisColorStyle, bandScale, bisectCenter, bisectLeft, bisectRight, brace, braceBetweenPoints, braceLabel, bulletedList, categoryScale, centroid, circle, circleConstraint, circleIntersections, circularLayout, circumscribedCircle, clamp, code, colorGradient, combine, cone3D, createAxisScales, createCamera, createCollisionScene, createDagreLayoutFn, createDominoes, createInteractive, createMovingCamera, createMovingCameraScene, createMultiBodyScene, createNewtonsCradle, createPendulum, createPhysicsWorld, createScene, createSpringMass, createTheme, createThreeDAxes, createThreeDCamera, createTimeline, cross, crossMark, cube3D, cubicBezier, cumsum, curvedArrow, curvedDoubleArrow, cutout, cylinder3D, deviation as d3Deviation, extent as d3Extent, group as d3Group, max as d3Max, mean as d3Mean, median as d3Median, merge as d3Merge, min as d3Min, normalize as d3Normalize, permute as d3Permute, quantile as d3Quantile, range as d3Range, sum as d3Sum, ticks as d3Ticks, transpose as d3Transpose, variance as d3Variance, dagreLayout, dashedStyle, decimalMatrix, decimalTable, defaultTheme, defaultTokens, degToRad, determinant, diagram_combine, diff, digraph, distance, div, donutLayout, dot, dot3D, doubleArrow, draw_to_svg, draw_to_svg_string, easing, easingMap, elbow, ellipse, empty, equilateralTriangle, footOfPerpendicular, functionConstraint, getBuffer, getColor, getCurrentTheme, getDefaultFillStyle, getDefaultStrokeStyle, getDefaultTextStyle, getDuration, getEasing, getGSAPEasing, getSpacing, getTheme, getTokens, graph, gridConstraint, gridLayout, group$1 as group, groupMulti, groupedHierarchicalLayout, hierarchicalLayout, histogram, inscribedCircle, integerMatrix, integerTable, interpolateColor, labeledDot, length, lerp, lerpNumber, lightTheme, line, line3D, lineConstraint, lineIntersection, linePoints, lineSegments, linearScale, logScale, manimTheme, mapRange, markupText, mathTable, matrix, matrixMultiply, median$1 as median, midpoint, mul, nearest, niceThresholds, normalize$1 as normalize, ordinalScale, orthocenter, orthogonalLayout, paragraph, parallelLine, path, pathFromString, perpendicular, perpendicularBisector, perpendicularLine, pieLayout, pointScale, polarConstraint, polygon, polyline, powScale, quadraticBezier, radToDeg, randomLayout, rate_functions, rect, rectConstraint, reflect, reflectOverPoint, reflectPoint, reflectPointOverLine, regularPolygon, regularPolygram, renderToRough, renderToSVG, resetTheme, rightAngleMarker, rolling, rotate, rotationMatrix, roughPresets, sampleCubicBezier, sampleParametric, scaleMatrix, sector, semanticStyle, setCurrentTheme, shuffle, sortGroups, sphere3D, springLayout, sqrtScale, square, stackLayout, stackedAreaPoints, star, sub, table, tangentLine, tex, text, themes, tickStep, toSVGString, translationMatrix, treeLayout, triangle, vector, dot$1 as vectorDot };