欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

canvas實現(xiàn)圖像布局填充功能

 更新時間:2017年02月06日 16:30:01   作者:藍(lán)丶木魚  
這篇文章主要為大家詳細(xì)介紹了canvas實現(xiàn)圖像布局填充功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了canvas圖像布局填充的具體代碼,供大家參考,具體內(nèi)容如下

<!DOCTYPE html> 
<html> 
<head lang="en"> 
  <meta charset="UTF-8"> 
  <title>canvas-圖像布局填充</title> 
  <style> 
    #canvas{ 
      border: 1px solid palevioletred; 
    } 
  </style> 
</head> 
<body> 
  <canvas id="canvas" width="600px" height="600px"> 
  </canvas> 
  <script> 
    //獲取到canvas元素 
    var canvas = document.getElementById('canvas'); 
    //獲取canvas中的畫圖環(huán)境 
    var context = canvas.getContext('2d'); 
 
    //創(chuàng)建Image對象 
    var img = new Image(); 
    //alert(img); 
    //引入圖片URL 
    img.src = "./image/huiji.png"; 
    window.onload = function (){ 
      //創(chuàng)建填充規(guī)則 .createPattern(圖像對象,'規(guī)則'); 第二參數(shù):repeat,no-repeat,repeat-x,repeat-y; 
       var pattern = context.createPattern(img,'no-repeat'); 
      //設(shè)置填充屬性 
      context.fillStyle = pattern; 
      context.fillRect(10,10,canvas.width,canvas.height); 
    } 
  </script> 
</body> 
</html> 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論