HTML5 Canvas 为网页添加文字水印


<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="3000" height="1500" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>

<script>
var can = document.createElement('canvas');
var body = document.body;
body.appendChild(can);
can.width=400;
can.height=200;
can.style.display='none';
var cans = can.getContext('2d');
//ctx.translate(-60, 0);//移动坐标原点
cans.rotate(-20*Math.PI/180);
cans.font = "16px Microsoft JhengHei";
cans.fillText("阿斯顿发送到!",can.width/3,can.height/2);
body.style.backgroundImage="url("+can.toDataURL("image/png")+")";

</script>

</body>
</html>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM