首页 > 其他 > 详细

canvas设置repeat

时间:2019-02-09 15:35:44      阅读:186      评论:0      收藏:0      [点我收藏+]

canvas设置repeat

  1. 方法

    ctx.createPattern(img, ‘repeat‘); 
    
    repeat
    repeat-x
    repeat-y
    no-repeat
  2. 重复图片

    技术分享图片

    const canvas = document.getElementById(‘canvas‘);
    const ctx = canvas.getContext(‘2d‘);
    
    var img = new Image();
    img.src = ‘http://thyrsi.com/t6/668/1549693913x2890173891.png‘;
    img.onload = function() {
        var ptrn = ctx.createPattern(img, ‘repeat‘);
        ctx.fillStyle = ptrn;
        ctx.fillRect(0, 0, 900, 700);
    }

canvas设置repeat

原文:https://www.cnblogs.com/ye-hcj/p/10357463.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!