@leafer/canvas 1.0.0-beta.7 → 1.0.0-beta.9
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 +9 -7
- package/src/Canvas.ts +1 -0
- package/src/CanvasManager.ts +1 -1
- package/src/LeaferCanvasBase.ts +12 -5
- package/src/index.ts +1 -1
- package/src/patch/index.ts +7 -0
- package/src/patch/roundRect.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/canvas",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "@leafer/canvas",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/file": "1.0.0-beta.
|
|
23
|
-
"@leafer/list": "1.0.0-beta.
|
|
24
|
-
"@leafer/math": "1.0.0-beta.
|
|
25
|
-
"@leafer/data": "1.0.0-beta.
|
|
26
|
-
"@leafer/
|
|
22
|
+
"@leafer/file": "1.0.0-beta.9",
|
|
23
|
+
"@leafer/list": "1.0.0-beta.9",
|
|
24
|
+
"@leafer/math": "1.0.0-beta.9",
|
|
25
|
+
"@leafer/data": "1.0.0-beta.9",
|
|
26
|
+
"@leafer/path": "1.0.0-beta.9",
|
|
27
|
+
"@leafer/debug": "1.0.0-beta.9",
|
|
28
|
+
"@leafer/platform": "1.0.0-beta.9"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.0.0-beta.
|
|
31
|
+
"@leafer/interface": "1.0.0-beta.9"
|
|
30
32
|
}
|
|
31
33
|
}
|
package/src/Canvas.ts
CHANGED
package/src/CanvasManager.ts
CHANGED
package/src/LeaferCanvasBase.ts
CHANGED
|
@@ -29,13 +29,14 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
29
29
|
public get allowBackgroundColor(): boolean { return this.view && this.parentView && !this.offscreen }
|
|
30
30
|
|
|
31
31
|
public bounds: IBounds
|
|
32
|
+
public clientBounds: IBoundsData
|
|
32
33
|
|
|
33
34
|
public config: ILeaferCanvasConfig
|
|
34
35
|
|
|
35
36
|
public autoLayout: boolean
|
|
36
37
|
|
|
37
|
-
public view:
|
|
38
|
-
public parentView:
|
|
38
|
+
public view: any
|
|
39
|
+
public parentView: any
|
|
39
40
|
|
|
40
41
|
public unreal?: boolean
|
|
41
42
|
|
|
@@ -63,12 +64,14 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
63
64
|
this.config = config
|
|
64
65
|
|
|
65
66
|
this.init()
|
|
66
|
-
|
|
67
|
-
this.textBaseline = "alphabetic"
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
public init(): void { }
|
|
71
70
|
|
|
71
|
+
protected __createContext(): void {
|
|
72
|
+
this.context = this.view.getContext('2d')
|
|
73
|
+
this.__bindContext()
|
|
74
|
+
}
|
|
72
75
|
|
|
73
76
|
public toBlob(type?: IExportFileType, quality?: number): Promise<IBlob> {
|
|
74
77
|
return new Promise((resolve) => {
|
|
@@ -131,6 +134,8 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
131
134
|
this.smooth = this.config.smooth
|
|
132
135
|
}
|
|
133
136
|
|
|
137
|
+
this.updateClientBounds()
|
|
138
|
+
|
|
134
139
|
if (this.context && !this.unreal && takeCanvas) {
|
|
135
140
|
this.clearWorld(takeCanvas.bounds)
|
|
136
141
|
this.copyWorld(takeCanvas)
|
|
@@ -139,6 +144,8 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
public updateViewSize(): void { }
|
|
147
|
+
public updateClientBounds(): void { }
|
|
148
|
+
|
|
142
149
|
public startAutoLayout(_autoBounds: IAutoBounds, _listener: IResizeEventListener): void { }
|
|
143
150
|
public stopAutoLayout(): void { }
|
|
144
151
|
|
|
@@ -205,7 +212,7 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
205
212
|
}
|
|
206
213
|
|
|
207
214
|
public hitFill(point: IPointData, fillRule?: IWindingRule): boolean {
|
|
208
|
-
return this.context.isPointInPath(point.x, point.y, fillRule)
|
|
215
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y)
|
|
209
216
|
}
|
|
210
217
|
|
|
211
218
|
public hitStroke(point: IPointData, strokeWidth?: number): boolean {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IPathDrawer } from '@leafer/interface'
|
|
2
|
+
import { RectHelper } from '@leafer/path'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const { drawRoundRect } = RectHelper
|
|
6
|
+
|
|
7
|
+
export function roundRect(drawer: IPathDrawer): void {
|
|
8
|
+
|
|
9
|
+
if (drawer && !drawer.roundRect) {
|
|
10
|
+
|
|
11
|
+
drawer.roundRect = function (x: number, y: number, width: number, height: number, cornerRadius: number | number[]): void {
|
|
12
|
+
|
|
13
|
+
drawRoundRect(this as IPathDrawer, x, y, width, height, cornerRadius)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|