@leafer/debug 1.5.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/debug",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "description": "@leafer/debug",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.5.3"
25
+ "@leafer/math": "1.6.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.5.3"
28
+ "@leafer/interface": "1.6.0"
29
29
  }
30
30
  }
package/src/Debug.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { IBooleanMap } from '@leafer/interface'
1
+ import { IBooleanMap, IBoundsData, ILeaferCanvas, IRenderOptions, ILeaf } from '@leafer/interface'
2
+ import { MathHelper } from '@leafer/math'
2
3
 
4
+
5
+ const { randColor } = MathHelper
3
6
  export class Debug {
4
7
 
5
8
  static enable: boolean
@@ -9,9 +12,8 @@ export class Debug {
9
12
 
10
13
  // other
11
14
  static showWarn = true
12
- static showRepaint: boolean
13
- static showHitView: boolean | string | string[]
14
- static showBoundsView: boolean | string | string[]
15
+ static showRepaint: boolean | string
16
+ static showBounds: boolean | string | 'hit'
15
17
 
16
18
  public name: string
17
19
 
@@ -33,6 +35,21 @@ export class Debug {
33
35
  this.excludeList = getNameList(name)
34
36
  }
35
37
 
38
+ static drawRepaint(canvas: ILeaferCanvas, bounds: IBoundsData): void {
39
+ const color = randColor()
40
+ canvas.fillWorld(bounds, color.replace('1)', '.1)'))
41
+ canvas.strokeWorld(bounds, color)
42
+ }
43
+
44
+ static drawBounds(leaf: ILeaf, canvas: ILeaferCanvas, _options: IRenderOptions): void {
45
+ const showHit = Debug.showBounds === 'hit', w = leaf.__nowWorld, color = randColor()
46
+ if (showHit) canvas.setWorld(w), leaf.__drawHitPath(canvas), canvas.fillStyle = color.replace('1)', '.2)'), canvas.fill()
47
+
48
+ canvas.resetTransform()
49
+ canvas.setStroke(color, 2)
50
+ showHit ? canvas.stroke() : canvas.strokeWorld(w, color)
51
+ }
52
+
36
53
 
37
54
  log(...messages: unknown[]): void {
38
55
  if (D.enable) {
package/src/Plugin.ts CHANGED
@@ -19,7 +19,7 @@ export const Plugin = {
19
19
  },
20
20
 
21
21
  need(name: string): any {
22
- console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name)
22
+ console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name)
23
23
  }
24
24
 
25
25
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IBooleanMap } from '@leafer/interface';
1
+ import { IBooleanMap, ILeaferCanvas, IBoundsData, ILeaf, IRenderOptions } from '@leafer/interface';
2
2
 
3
3
  interface ids {
4
4
  [name: string]: number;
@@ -22,15 +22,16 @@ declare class Debug {
22
22
  static filterList: string[];
23
23
  static excludeList: string[];
24
24
  static showWarn: boolean;
25
- static showRepaint: boolean;
26
- static showHitView: boolean | string | string[];
27
- static showBoundsView: boolean | string | string[];
25
+ static showRepaint: boolean | string;
26
+ static showBounds: boolean | string | 'hit';
28
27
  name: string;
29
28
  repeatMap: IBooleanMap;
30
29
  constructor(name: string);
31
30
  static get(name: string): Debug;
32
31
  static set filter(name: string | string[]);
33
32
  static set exclude(name: string | string[]);
33
+ static drawRepaint(canvas: ILeaferCanvas, bounds: IBoundsData): void;
34
+ static drawBounds(leaf: ILeaf, canvas: ILeaferCanvas, _options: IRenderOptions): void;
34
35
  log(...messages: unknown[]): void;
35
36
  tip(...messages: unknown[]): void;
36
37
  warn(...messages: unknown[]): void;