方法水印字体和透明度
This commit is contained in:
parent
879dfb8a74
commit
9a9cc62d22
@ -1,14 +1,15 @@
|
|||||||
// 页面添加水印效果
|
// 页面添加水印效果
|
||||||
const setWatermark = (str: string) => {
|
const setWatermark = (str: string) => {
|
||||||
const id = '1.23452384164.123412416';
|
const id = '1.23452384164.123412416';
|
||||||
if (document.getElementById(id) !== null) document.body.removeChild(<HTMLElement>document.getElementById(id));
|
if (document.getElementById(id) !== null)
|
||||||
|
document.body.removeChild(<HTMLElement>document.getElementById(id));
|
||||||
const can = document.createElement('canvas');
|
const can = document.createElement('canvas');
|
||||||
can.width = 200;
|
can.width = 200;
|
||||||
can.height = 130;
|
can.height = 130;
|
||||||
const cans = <CanvasRenderingContext2D>can.getContext('2d');
|
const cans = <CanvasRenderingContext2D>can.getContext('2d');
|
||||||
cans.rotate((-20 * Math.PI) / 180);
|
cans.rotate((-20 * Math.PI) / 180);
|
||||||
cans.font = '12px Vedana';
|
cans.font = '18px Vedana';
|
||||||
cans.fillStyle = 'rgba(200, 200, 200, 0.30)';
|
cans.fillStyle = 'rgba(200, 200, 200, 0.40)';
|
||||||
cans.textBaseline = 'middle';
|
cans.textBaseline = 'middle';
|
||||||
cans.fillText(str, can.width / 10, can.height / 2);
|
cans.fillText(str, can.width / 10, can.height / 2);
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
@ -38,8 +39,9 @@ const watermark = {
|
|||||||
},
|
},
|
||||||
// 删除水印
|
// 删除水印
|
||||||
del: () => {
|
del: () => {
|
||||||
let id = '1.23452384164.123412416';
|
const id = '1.23452384164.123412416';
|
||||||
if (document.getElementById(id) !== null) document.body.removeChild(<HTMLElement>document.getElementById(id));
|
if (document.getElementById(id) !== null)
|
||||||
|
document.body.removeChild(<HTMLElement>document.getElementById(id));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user