<html>
<head>
<style>
canvas { margin:auto; display:block; }
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
var canvas = document.getElementById('canvas');
var a = 6;
canvas.width = 210 * a;
canvas.height = 297 * a;
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0,0,canvas.width,canvas.height);
ctx.font = '30px Arial';
var dx = Math.random()*200;
var dy = Math.random()*200;
var img1 = new Image();
img1.src = 'sfz1.jpg';
img1.onload = function() { draw(); };
var img2 = new Image();
img2.src = 'sfz2.jpg';
img2.onload = function() { draw(); };
function draw() {
if (img1.complete && img2.complete) {
var dw = 85.6 * a;
var dh = 54 * a;
ctx.drawImage(img1, canvas.width/2 - dw/2, canvas.height / 2 - 1.5 * dh, dw, dh);
ctx.drawImage(img2, canvas.width/2 - dw/2, canvas.height / 2 + 0.5 * dh, dw, dh);
ctx.save();
ctx.fillStyle = 'gray';
ctx.rotate(-Math.PI/4);
var t = '劳动能力鉴定';
var tw = ctx.measureText(t).width;
for (x=-canvas.width; x<canvas.width; x+=2*tw) {
for (y=0; y<1.5*canvas.height; y+=tw) {
ctx.fillText(t, x + dx, y + dy);
}
}
ctx.restore();
}
}
</script>
</body>
</html>
身份证水印
于 2023-11-22 18:38:07 首次发布