zoukankan      html  css  js  c++  java
  • canvas添加水印

    <canvas id="canvas"></canvas>
    <canvas id="water"></canvas>
    <img src="" id="imgShow" alt=""/>


    var ca = document.getElementById("canvas");
    var ctx = ca.getContext("2d");

    var water = document.getElementById("water");
    var waterCtx = water.getContext("2d");

    var imgShow = document.getElementById("imgShow");

    ca.width = 900;
    ca.height = 600;

    water.width = 200;
    water.height = 50;

    var img = new Image();

    img.src = "img.jpg";

    // 水印canvas的样式
    waterCtx.font = "30px Aril bold";
    waterCtx.fillStyle = "rgba(0,0,0,.3)";
    waterCtx.textBaseline = "midddle";
    waterCtx.fillText("芳芳芳芳付", 20, 30);

    // 图片加载完后,去执行其他操作
    img.onload = function(){
    ctx.drawImage(img,ca.width - img.width,ca.height - img.height);
    ctx.drawImage(water,ca.width - water.width,ca.height - water.height);
    var imgOut = ca.toDataURL("image/jpeg");
    imgShow.src = imgOut;
    }



  • 相关阅读:
    性能测试目的和性能测试主要术语
    回数
    python求100以内的素数
    杨辉三角
    裴波那契数列
    day12_框架二sendmail.py代码
    codeforces 1435 E
    codeforces C
    codeforces 1436E
    codeforces 1435 D. Shurikens (贪心)
  • 原文地址:https://www.cnblogs.com/founderswitch/p/7243702.html
Copyright © 2011-2022 走看看