Vote count:
0
I design a object named "Lottory"
function Lottery(canvas, cover_img, width, height){
this.canvas = canvas;
this.context = this.canvas.getContext("2d");
this.width = width;
this.height = height;
this.cover_img = cover_img;
}
and a method init()
Lottery.prototype = {
init: function(){
var _this = this;
var image = new Image();
image.src = this.cover_img;
image.onload = function(){
_this.context.drawImage(image, 0, 0, _this.width, _this.height);
}
}
}
When I use this, it can't draw a image on my canvas, Why?
var canvas = document.getElementById("cv");
var context = canvas.getContext("2d");
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
var cover = new Lottery(canvas,"index_blur.jpg", canvas.height, canvas.width);
cover.init();
asked 1 min ago
can't draw a image in canvas
Aucun commentaire:
Enregistrer un commentaire