@leafer/canvas 1.0.0-rc.6 → 1.0.0-rc.7
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 -9
- package/src/Canvas.ts +2 -3
- package/src/HitCanvasManager.ts +2 -2
- package/src/LeaferCanvasBase.ts +6 -5
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/canvas",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.7",
|
|
4
4
|
"description": "@leafer/canvas",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/file": "1.0.0-rc.
|
|
26
|
-
"@leafer/list": "1.0.0-rc.
|
|
27
|
-
"@leafer/math": "1.0.0-rc.
|
|
28
|
-
"@leafer/data": "1.0.0-rc.
|
|
29
|
-
"@leafer/path": "1.0.0-rc.
|
|
30
|
-
"@leafer/debug": "1.0.0-rc.
|
|
31
|
-
"@leafer/platform": "1.0.0-rc.
|
|
25
|
+
"@leafer/file": "1.0.0-rc.7",
|
|
26
|
+
"@leafer/list": "1.0.0-rc.7",
|
|
27
|
+
"@leafer/math": "1.0.0-rc.7",
|
|
28
|
+
"@leafer/data": "1.0.0-rc.7",
|
|
29
|
+
"@leafer/path": "1.0.0-rc.7",
|
|
30
|
+
"@leafer/debug": "1.0.0-rc.7",
|
|
31
|
+
"@leafer/platform": "1.0.0-rc.7"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@leafer/interface": "1.0.0-rc.
|
|
34
|
+
"@leafer/interface": "1.0.0-rc.7"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/Canvas.ts
CHANGED
|
@@ -3,11 +3,10 @@ import { ICanvasAttr, ITextMetrics, ICanvasContext2D, IPath2D, IObject, InnerId,
|
|
|
3
3
|
function contextAttr(realName?: string) {
|
|
4
4
|
return (target: Canvas, key: string) => {
|
|
5
5
|
if (!realName) realName = key
|
|
6
|
-
|
|
6
|
+
Object.defineProperty(target, key, {
|
|
7
7
|
get() { return (this.context as IObject)[realName] },
|
|
8
8
|
set(value: unknown) { (this.context as IObject)[realName] = value }
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(target, key, property)
|
|
9
|
+
} as ThisType<Canvas>)
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
|
package/src/HitCanvasManager.ts
CHANGED
|
@@ -11,12 +11,12 @@ export class HitCanvasManager extends CanvasManager implements IHitCanvasManager
|
|
|
11
11
|
protected imageTypeList: ILeafList = new LeafList()
|
|
12
12
|
|
|
13
13
|
public getImageType(leaf: ILeaf, size: IScreenSizeData): IHitCanvas {
|
|
14
|
-
this.imageTypeList.
|
|
14
|
+
this.imageTypeList.add(leaf)
|
|
15
15
|
return Creator.hitCanvas(size)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
public getPathType(leaf: ILeaf): IHitCanvas {
|
|
19
|
-
this.pathTypeList.
|
|
19
|
+
this.pathTypeList.add(leaf)
|
|
20
20
|
return Creator.hitCanvas()
|
|
21
21
|
}
|
|
22
22
|
|
package/src/LeaferCanvasBase.ts
CHANGED
|
@@ -283,7 +283,7 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
283
283
|
public fillWorld(bounds: IBoundsData, color: string | object, blendMode?: IBlendMode): void {
|
|
284
284
|
if (blendMode) this.blendMode = blendMode
|
|
285
285
|
this.fillStyle = color
|
|
286
|
-
temp.
|
|
286
|
+
temp.set(bounds).scale(this.pixelRatio)
|
|
287
287
|
this.fillRect(temp.x, temp.y, temp.width, temp.height)
|
|
288
288
|
if (blendMode) this.blendMode = 'source-over'
|
|
289
289
|
}
|
|
@@ -291,20 +291,20 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
291
291
|
public strokeWorld(bounds: IBoundsData, color: string | object, blendMode?: IBlendMode): void {
|
|
292
292
|
if (blendMode) this.blendMode = blendMode
|
|
293
293
|
this.strokeStyle = color
|
|
294
|
-
temp.
|
|
294
|
+
temp.set(bounds).scale(this.pixelRatio)
|
|
295
295
|
this.strokeRect(temp.x, temp.y, temp.width, temp.height)
|
|
296
296
|
if (blendMode) this.blendMode = 'source-over'
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
public clearWorld(bounds: IBoundsData, ceilPixel?: boolean): void {
|
|
300
|
-
temp.
|
|
300
|
+
temp.set(bounds).scale(this.pixelRatio)
|
|
301
301
|
if (ceilPixel) temp.ceil()
|
|
302
302
|
this.clearRect(temp.x, temp.y, temp.width, temp.height)
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
public clipWorld(bounds: IBoundsData, ceilPixel?: boolean): void {
|
|
306
306
|
this.beginPath()
|
|
307
|
-
temp.
|
|
307
|
+
temp.set(bounds).scale(this.pixelRatio)
|
|
308
308
|
if (ceilPixel) temp.ceil()
|
|
309
309
|
this.rect(temp.x, temp.y, temp.width, temp.height)
|
|
310
310
|
this.clip()
|
|
@@ -324,7 +324,7 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
// 需要有 manager变量
|
|
327
|
-
public getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas {
|
|
327
|
+
public getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas {
|
|
328
328
|
const { width, height, pixelRatio } = this
|
|
329
329
|
|
|
330
330
|
const options = { width, height, pixelRatio }
|
|
@@ -333,6 +333,7 @@ export class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
333
333
|
canvas.save()
|
|
334
334
|
|
|
335
335
|
if (useSameWorldTransform) canvas.useWorldTransform({ ...this.worldTransform })
|
|
336
|
+
if (useSameSmooth) canvas.smooth = this.smooth
|
|
336
337
|
|
|
337
338
|
return canvas
|
|
338
339
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ declare class LeaferCanvasBase extends Canvas implements ILeaferCanvas {
|
|
|
146
146
|
clipWorld(bounds: IBoundsData, ceilPixel?: boolean): void;
|
|
147
147
|
clear(): void;
|
|
148
148
|
isSameSize(size: IScreenSizeData): boolean;
|
|
149
|
-
getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas;
|
|
149
|
+
getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas;
|
|
150
150
|
getBiggerCanvas(addWidth: number, addHeight: number): ILeaferCanvas;
|
|
151
151
|
recycle(): void;
|
|
152
152
|
updateRender(): void;
|