当我被枪杀时,我想要画一幅画像,但我不能。
我应该修理什么?
var brush = new Image();
brush.src = "http://icons.iconarchive.com/icons/designcontest/vintage/256/Brush-icon.png"
brush.onload = function(){
$("<canvas></canvas>").appendTo("body");
var canvas = $('canvas');
var context = canvas[0].getContext('2d');
canvas.width(500).height(300);
$('canvas').mousedown(function(event){
alert('canvas clicked on coordinates ('+event.pageX+','+event.pageY+')');
contex.drawImage(brush, event.pageX, event.pageY);
})
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
</body>
答案 0 :(得分:1)
您错误输入了单词&#34; context&#34;:
contex.drawImage(brush, event.pageX, event.pageY);
应该是
context.drawImage(brush, event.pageX, event.pageY);