问答详情
源自:5-3 使用图片、画布或者video

com.createdPattern is not a function at Image.imgs.onload

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Html5 Canvas 实现图片合成</title>

<script src="../js/jq.js"></script>

<script src="../js/base64js.min.js"></script>

<script src="../js/canvas2image.js"></script>

<script src="../js/html2canvas.js"></script>

<style>

img{border:solid 1px #ddd;}

.c-box{

display: flex;

padding: 15px;

justify-content: space-between;

}

.c-img{

display: block;

width: 45%;

height:260px;

}

.btn{

width: 40%;

height: 40px;

line-height: 40px;

text-align: center;

color: #fff;

background-color: brown;

font-size: 14px;

margin: 20px auto;

}

#imgbox{

width: 300px;

height: 500px;

}

</style>

</head>


<body>

<canvas id="canvas"></canvas>

<!-- <div align="center" class="img_photo">

   <img src="../image/canvas.jpg" alt="" class="c-img">

   <img src="../image/cq.jpg" alt="" class="c-img">

</div>

<input type="button" value="一键合成" onClick="draw()" style="display:block;width: 60px; margin: 0 auto;">

<div id="imgBox" align="center"></div> -->

<script>

var canvas=document.querySelector("#canvas")

var com=canvas.getContext('2d')

canvas.width=400;

canvas.height=400;

//   com.rect(0,0,canvas.width,canvas.height);

//   com.fillStyle='#aaa';//画布填充颜色

//   com.fill();



var imgs=new Image()

imgs.src='../image/canvas.jpg'

imgs.onload=function(){

var patter=com.createdPattern(imgs,'no-repeat')

com.fillStyle=patter

com.fillRect(0,0,400,400)

}

</script>

</body>

</html>


提问者:慕无忌1532157 2019-06-25 18:42

个回答

  • 爪哇_2015
    2019-07-01 11:33:51

    com.createdPattern is not a function多明显,createPattern不是createdPattern