这是我为画布制作的那种。我想当我点击左/右按钮时,画布的背景图像属性应该改变。
enyo.kind({
name:"enyo.sample.imagecanvas",
kind:"Control",
components:[
{kind:"enyo.Control",tag:"img",name:"left",ontap:"lefttap",src:"assets/left_arrow.p ng",fit:true},
{kind:enyo.Control,tag:"canvas",name:"canvas",index:"0",attributes:{width:1000,height:650},fit:true,src:"assets/1.jpg"},
{kind:"enyo.Control",tag:"img",name:"right",ontap:"righttap",src:"assets/right_arrow.png",fit:true},
],
imgsrc:["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg","9.jpg"],
lefttap:function(){
var index=this.$.canvas.index;
index++;
if(index > 8){
index = 0;
}
//how to change canvas background image.
},
righttap:function(){
}
})
有人可以建议怎么做吗?
答案 0 :(得分:0)
我会使用画布上下文的drawImage方法。或者,如果您要在画布上绘制其他内容,可以将图像放在画布后面的div中。只需将画布的背景设置为透明。
请参阅:http://www.html5canvastutorials.com/tutorials/html5-canvas-images/