[英]I am trying to draw shapes using mouse events in jcanvas
I am trying to draw shapes on canvas using mouse events in JCanvas. 我正在尝试使用JCanvas中的鼠标事件在画布上绘制形状。 I am trying to implement it by creating a temporary canvas to draw shapes. 我正在尝试通过创建临时画布来绘制形状来实现它。 My question here is can we implement temporary canvas in JCanvas? 我的问题是我们可以在JCanvas中实现临时画布吗? I am not getting any idea of how to draw shapes on canvas in JCanvas using mouseevents. 我对如何使用mouseevents在JCanvas的画布上绘制形状一无所知。 Can you please give a basic example of using mouse events to draw shapes in jcanvas. 您能否举一个使用鼠标事件在jcanvas中绘制形状的基本示例。
Thanks in advance. 提前致谢。
Have you tried to copy what is being done here: 您是否尝试过复制此处执行的操作:
http://calebevans.me/projects/painter/ http://calebevans.me/projects/painter/
They use this script to draw: 他们使用此脚本绘制:
(function (e) {
e.fn.brushTool = function () {
function i() {
e.drawArc({
fillStyle: color,
x: n,
y: r,
radius: stroke / 2
})
}
var e = this;
e.unbind();
var t = !1,
n, r;
e.on(getTouchEventName("mousedown"), function (s) {
hist.push(last.src = e[0].toDataURL("image/png"));
t = !0;
n = s.offsetX;
r = s.offsetY;
i();
return !1
});
e.on(getTouchEventName("mouseup"), function () {
t = !1
});
e.on(getTouchEventName("mousemove"), function (e) {
if (t === !0) {
n = e.offsetX;
r = e.offsetY;
i()
}
})
}
})(jQuery);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.