ranuts 0.1.0-alpha.13 → 0.1.0-alpha.15

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.
@@ -77,6 +77,7 @@ export declare class Chain {
77
77
  * @return {Chain}
78
78
  */
79
79
  setStyle: (name: string, value: string) => Chain;
80
+ private addElementByType;
80
81
  /**
81
82
  * @description: 给当前元素添加子元素
82
83
  * @return {Chain}
@@ -3027,6 +3027,15 @@ class Chain {
3027
3027
  this.element.style.setProperty(name, value);
3028
3028
  return this;
3029
3029
  });
3030
+ // 根据不同的子元素类型,添加元素
3031
+ __publicField(this, "addElementByType", (item, parent) => {
3032
+ if (item instanceof Chain) {
3033
+ parent.appendChild(item.element);
3034
+ }
3035
+ if (item instanceof HTMLElement) {
3036
+ parent.appendChild(item);
3037
+ }
3038
+ });
3030
3039
  /**
3031
3040
  * @description: 给当前元素添加子元素
3032
3041
  * @return {Chain}
@@ -3034,10 +3043,12 @@ class Chain {
3034
3043
  __publicField(this, "addChild", (child) => {
3035
3044
  if (Array.isArray(child)) {
3036
3045
  const Fragment = document.createDocumentFragment();
3037
- child.forEach((item) => Fragment.appendChild(item.element));
3046
+ child.forEach((item) => {
3047
+ this.addElementByType(item, Fragment);
3048
+ });
3038
3049
  this.element.appendChild(Fragment);
3039
3050
  } else {
3040
- this.element.appendChild(child.element);
3051
+ this.addElementByType(child, this.element);
3041
3052
  }
3042
3053
  return this;
3043
3054
  });
@@ -1,19 +1,22 @@
1
- import { Container } from "@/utils/visual/vertex/container";
2
- import { Polygon } from "@/utils/visual/shape/polygon";
3
- import type { Shape } from "@/utils/visual/shape/shape";
1
+ import { Container } from '@/utils/visual/vertex/container';
2
+ import { Polygon } from '@/utils/visual/shape/polygon';
3
+ import type { Shape } from '@/utils/visual/shape/shape';
4
4
  import type { CanvasRenderer } from '@/utils/visual/render/canvasRenderer';
5
+ import type { Point } from '@/utils/visual/vertex/point';
5
6
  export declare class Graphics extends Container {
6
7
  private _lineStyle;
7
8
  private _fillStyle;
8
9
  private _geometry;
9
10
  currentPath: Polygon | null;
11
+ type: string;
10
12
  constructor();
11
13
  protected drawShape(shape: Shape): Graphics;
12
14
  /**
13
- * 清空已有的 path,开始新的 path
14
- */
15
+ * 清空已有的 path,开始新的 path
16
+ */
15
17
  protected startPoly(): void;
16
18
  beginFill(color?: string, alpha?: number): Graphics;
17
19
  drawRect(x: number, y: number, width: number, height: number): Graphics;
18
20
  protected renderCanvas(render: CanvasRenderer): void;
21
+ containsPoint(p: Point): boolean;
19
22
  }
@@ -1,6 +1,6 @@
1
- import type { Shape } from "@/utils/visual/shape/shape";
2
- import type { Fill } from "@/utils/visual/style/fill";
3
- import type { Line } from "@/utils/visual/style/line";
1
+ import type { Shape } from '@/utils/visual/shape/shape';
2
+ import type { Fill } from '@/utils/visual/style/fill';
3
+ import type { Line } from '@/utils/visual/style/line';
4
4
  export declare class GraphicsData {
5
5
  shape: Shape;
6
6
  lineStyle: Line;
@@ -1,10 +1,16 @@
1
- import type { Shape } from "@/utils/visual/shape/shape";
2
- import type { Fill } from "@/utils/visual/style/fill";
3
- import type { Line } from "@/utils/visual/style/line";
1
+ import type { Shape } from '@/utils/visual/shape/shape';
2
+ import type { Fill } from '@/utils/visual/style/fill';
3
+ import type { Line } from '@/utils/visual/style/line';
4
4
  import { GraphicsData } from '@/utils/visual/graphics/graphicsData';
5
+ import type { Point } from '@/utils/visual/vertex/point';
5
6
  export declare class GraphicsGeometry {
6
7
  graphicsData: GraphicsData[];
7
8
  constructor();
8
9
  drawShape(shape: Shape, fillStyle: Fill, lineStyle: Line): void;
9
10
  clear(): void;
11
+ /**
12
+ * @param p 待检测点
13
+ * @returns {boolean} 待检测点是否落在某一个子图形内
14
+ */
15
+ containsPoint(p: Point): boolean;
10
16
  }
@@ -1,5 +1,5 @@
1
- import type { ShapeType } from "@/utils/visual/enums";
2
- import type { Point } from "@/utils/visual/vertex/point";
1
+ import type { ShapeType } from '@/utils/visual/enums';
2
+ import type { Point } from '@/utils/visual/vertex/point';
3
3
  export declare abstract class Shape {
4
4
  abstract type: ShapeType;
5
5
  constructor();
@@ -6,7 +6,6 @@
6
6
  "esModuleInterop": true,
7
7
  "target": "ESNext",
8
8
  "moduleResolution": "bundler",
9
- "types": ["./typings.d.ts"],
10
9
  "outDir": "dist",
11
10
  "forceConsistentCasingInFileNames": true,
12
11
  "noFallthroughCasesInSwitch": true,