有人可以帮助我解决此问题吗? 如何将大小为300px * 300 px的图像(例如300px * 300 px)添加到Canvas中,例如,1000px * 1000 px?
Thx)
答案 0 :(得分:-1)
我不确定您要问的是什么,但我认为您需要做的是以某种方式使画布动画。今晚上班:
var canvas1 = {
canvas : document.createElement("canvas"),
start : function() {
this.canvas.width = 480;
this.canvas.height = 480;
this.cxt = this.canvas.getContext("2d");
document.body.insertBefore(this.canvas, document.body.childNodes[0]);
this.frameNo = 0;
this.interval = setInterval(updateCanvas, 20),
clear : function() {
this.cxt.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
};
然后是某种更新功能,例如:
function updateCanvas() {
var //whatever variables you need;
//add pictures
canvas1.clear(); //clear before adding anything else
}
我希望这会有所帮助!更新:忽略画布大小,我知道我应该不正确,我从另一个项目中部分复制了它