1 Star 1 Fork 0

Redxym / watermark-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
watermark.min.js 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
Redxym 提交于 2022-05-23 11:25 . 删除冗余代码
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.watermark=e():t.watermark=e()}(self,function(){"use strict";var t={};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o,n=arguments[e];for(o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function o(t){if((o=t).w_texts&&"[object Array]"!==Object.prototype.toString.call(o.w_texts)?(alert("水印文字参数必须是数组类型"),!1):!!o.w_texts.length||(alert("水印文字数组的长度必须大于0"),!1)){for(var e={},e=t.w_options&&"[object Object]"===Object.prototype.toString.call(t.w_options)?c({},d,t.w_options):c({},d),o="3.14159261111",n=(null!==document.getElementById(o)&&document.body.removeChild(document.getElementById(o)),document.createElement("canvas")),l=(n.width=e.width,n.height=e.height,n.getContext("2d")),i=(l.rotate(-(e.rotateDeg*Math.PI)/180),l.font=e.fontSize+"px "+e.fontFamily,l.fillStyle=e.color,l.textAlign=e.textAlign,t.w_texts),r=0;r<i.length;r++){var a=i[r]||" ";l.fillText(a,n.width/16,n.height/2+r*e.fontSize)}t=document.createElement("div");return t.id=o,t.style.width=document.documentElement.clientWidth-10+"px",t.style.height=document.documentElement.clientHeight-20+"px",t.style.pointerEvents="none",t.style.position="fixed",t.style.top=e.top,t.style.left=e.left,t.style.opacity=e.opacity,t.style.background="url("+n.toDataURL()+") left top repeat",t.style.zIndex=e.zIndex,document.body.appendChild(t),o}}var e={},d={width:200,height:100,top:"0px",left:"0px",fontSize:"16",fontFamily:"serif",fillStyle:"rgba(200, 200, 200, 0.8)",color:"#666",opacity:"0.8",textAlign:"left",rotateDeg:20,zIndex:999999};return e.setWatermark=function(t){var e=o(t);null===document.getElementById(e)&&o(t),window.onresize=function(){o(t)}},e.removeWatermark=function(){var t=document.getElementById("3.14159261111");null!==t&&document.body.removeChild(t)},t.default=e,t=t.default});
JavaScript
1
https://gitee.com/redxym/watermark-demo.git
git@gitee.com:redxym/watermark-demo.git
redxym
watermark-demo
watermark-demo
master

搜索帮助