import {create} from 'auto-image-watermark';
const H5 = create({
width: 375,
height: 600,
backgroundColor: '#fff',
debug: false,
pixelRatio: 2,
blocks: [{
width: 650,
height: 300,
x: 1,
y: 2,
borderWidth: 4,
borderColor: '#000',
borderRadius: 30,
backgroundColor: '#fff',
text: {
text: [{
x: 12,
y: 40,
text: '块中的文字',
fontSize: 35,
color: '#f00',
width: 300
},
{
x: 182,
y: 90,
text: '过长文字缩略',
fontSize: 35,
color: '#f76',
width: 300
}
]
},
zIndex: 1
},
{
width: 650,
height: 200,
x: 10,
y: 400,
borderWidth: 6,
borderColor: '#ff00ff',
borderRadius: 50,
backgroundColor: '#ff0',
opacity: 0.5,
zIndex: 2
},
],
lines: [{
startX: 250,
startY: 250,
endX: 550,
endY: 250,
width: 9,
color: 'green',
zIndex: 128
}],
texts: [{
x: 113,
y: 132,
text: 'hello world',
fontSize: 57,
baseLine: 'middle',
textAlign: 'left',
color: 'rgba(255,0,0)',
zIndex: 8
}, ],
images: [{
width: 276,
x: 74,
y: 170,
borderRadius: 12,
borderColor: '#f30',
borderWidth: 4,
url: 'https://lc-I0j7ktVK.cn-n1.lcfile.com/02bb99132352b5b5dcea.jpg',
zIndex: 40
}
]
});
1.zIndex代表block、image、line、text之间的层级关系,层级越大,显示层级在越靠上;
2.blocks中的text的zIndex无效;
3.images中需要生成圆形图片则设置图片width、height、borderRadius三者相等即可;
4.单位统一(px);