@leafer/image 1.8.0 → 1.9.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 +7 -7
- package/src/LeaferImage.ts +3 -2
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/image",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "@leafer/image",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/task": "1.
|
|
26
|
-
"@leafer/file": "1.
|
|
27
|
-
"@leafer/data": "1.
|
|
28
|
-
"@leafer/math": "1.
|
|
29
|
-
"@leafer/platform": "1.
|
|
25
|
+
"@leafer/task": "1.9.0",
|
|
26
|
+
"@leafer/file": "1.9.0",
|
|
27
|
+
"@leafer/data": "1.9.0",
|
|
28
|
+
"@leafer/math": "1.9.0",
|
|
29
|
+
"@leafer/platform": "1.9.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.
|
|
32
|
+
"@leafer/interface": "1.9.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/LeaferImage.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ImageManager } from './ImageManager'
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const { IMAGE, create } = IncrementId
|
|
11
|
+
const { floor, max } = Math
|
|
11
12
|
|
|
12
13
|
export class LeaferImage implements ILeaferImage {
|
|
13
14
|
|
|
@@ -105,7 +106,7 @@ export class LeaferImage implements ILeaferImage {
|
|
|
105
106
|
return this.view
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
public getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): any {
|
|
109
|
+
public getCanvas(width: number, height: number, opacity?: number, _filters?: IObject, xGap?: number, yGap?: number): any {
|
|
109
110
|
width || (width = this.width)
|
|
110
111
|
height || (height = this.height)
|
|
111
112
|
|
|
@@ -115,7 +116,7 @@ export class LeaferImage implements ILeaferImage {
|
|
|
115
116
|
if (data) return data
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
const canvas = Platform.origin.createCanvas(width, height)
|
|
119
|
+
const canvas = Platform.origin.createCanvas(max(floor(width + (xGap || 0)), 1), max(floor(height + (yGap || 0)), 1))
|
|
119
120
|
const ctx = canvas.getContext('2d')
|
|
120
121
|
if (opacity) ctx.globalAlpha = opacity
|
|
121
122
|
ctx.drawImage(this.view, 0, 0, width, height)
|
package/types/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare class LeaferImage implements ILeaferImage {
|
|
|
24
24
|
protected onProgress(progress: IProgressData): void;
|
|
25
25
|
protected onComplete(isSuccess: boolean): void;
|
|
26
26
|
getFull(_filters?: IObject): any;
|
|
27
|
-
getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): any;
|
|
27
|
+
getCanvas(width: number, height: number, opacity?: number, _filters?: IObject, xGap?: number, yGap?: number): any;
|
|
28
28
|
getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern;
|
|
29
29
|
destroy(): void;
|
|
30
30
|
}
|