uni-canvas-image 1.1.2 → 1.1.3
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 +1 -1
- package/src/common/index.js +3 -2
- package/src/util/attractImage.js +1 -1
package/package.json
CHANGED
package/src/common/index.js
CHANGED
|
@@ -47,10 +47,11 @@ export async function base64ToBlob(base64Data) {
|
|
|
47
47
|
return await response.blob()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export async function drawImageToCanvas(arr, canvasId = 'canvas-1', api) {
|
|
50
|
+
export async function drawImageToCanvas(arr, canvasId = 'canvas-1', api, config) {
|
|
51
51
|
return new Promise((resolve, reject) => {
|
|
52
|
+
const { bgc = '#fff' } = config || {}
|
|
52
53
|
const ctx = uni.createCanvasContext(canvasId)
|
|
53
|
-
ctx.setFillStyle(
|
|
54
|
+
ctx.setFillStyle(bgc)
|
|
54
55
|
ctx.fillRect(0, 0, 375, 300)
|
|
55
56
|
arr.forEach((item) => {
|
|
56
57
|
if (item.type === 'image') {
|
package/src/util/attractImage.js
CHANGED
|
@@ -33,7 +33,7 @@ async function attractImage(params) {
|
|
|
33
33
|
data.mainBuilding = data.mainBuilding.join('、').length > 11 ? data.mainBuilding.join('、').slice(0, 11) + '...' : data.mainBuilding.join('、')
|
|
34
34
|
const newBuildingInfo = { type: 'text', text: data.mainBuilding, x: 80, y: 258, color: '#fff', fontSize: 14 }
|
|
35
35
|
const newObj = [...staticInfo, newAreaInfo, newImgInfo, maskInfo, buildingLabel, newBuildingInfo]
|
|
36
|
-
const url = await drawImageToCanvas(newObj, canvasId, api)
|
|
36
|
+
const url = await drawImageToCanvas(newObj, canvasId, api, { bgc: '#f2f2f2' })
|
|
37
37
|
resolve(url)
|
|
38
38
|
})
|
|
39
39
|
}
|