即时使用此http://projects.calebevans.me/jcanvas/ 我有简单的例子
class OrderedArray<T: Comparable<T>>(
private val items: Array<T>,
private val comparator: Comparator<in T> = naturalOrder<T>())
和js
<input type="button" class="bt" value="draw"/><br>
<canvas id="picture" width=1350 height=1350></canvas>
如果我点击按钮bt,然后悬停画布div,我的背景就会消失 我如何能够在背景上绘制新图像
答案 0 :(得分:1)
您的背景会被删除,因为您正在使用ctx.drawImage
,而drawLayers()
不会创建jCanvas图层。 jCanvas图层和非图层不能存在于同一画布上,因为当jCanvas重绘画布时(通过"tank_usa.jpg"
手动重绘或触发事件时自动重绘),非图层将被删除。
要解决此问题,只需绘制'facesSmall.png'
,就像您提到addLayer
一样:使用type: 'image'
设置$('#picture').addLayer({
type: 'image',
source: 'tank_usa.jpg',
x: 0, y: 0,
fromCenter: false
});
$(".bt").on("click",function(){
// Draw a resizable image
$('#picture').addLayer({
type: 'image',
draggable: true,
source: 'facesSmall.png',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 2,
x: 180, y: 150,
width: 200, height: 125,
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 2,
radius: 10
}
})
.drawLayer();
});
。
/admin/topics