简体   繁体   English

我正在尝试使用jcanvas中的鼠标事件绘制形状

[英]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.

相关问题 我正在尝试使用JCanvas中的鼠标事件在画布上绘制线条和矩形 - I am trying to draw a line and rectangle on canvas using mouse events in JCanvas 我正在尝试通过使用鼠标事件在画布上画一条线 - I am trying to draw a line on canvas by using mouse events 我无法实现JCanvas - I am unable to implement JCanvas 我正在尝试创建一个鼠标事件,允许用户使用“ ctrl”键和Shift键绘制红色或蓝色 - I am trying to create a mouse event that allows the user to draw in red or blue using the “ctrl” key and the shift key 如何在Javascript中使用鼠标事件在画布上绘画 - How to draw on canvas using mouse events with Javascript paperjs 使用鼠标事件绘制 0 到 360º 弧 - paperjs draw 0 to 360º arc using mouse events 如何用鼠标在Three.js中绘制形状? - How can I draw shapes in Three.js with mouse? 我正在尝试在 plotyjs 中单击鼠标绘制直线,并将图像加载为背景 - I am trying to draw straight lines on mouse click in plotyjs with image loaded as background 尝试绘制从鼠标位置的工具栏选择的形状-HTML5 CANVAS - Trying to draw shapes which are selected from toolbar at the mouse position-HTML5 CANVAS 无法使用鼠标事件在JavaScript中的画布上绘制一个完整的圆圈 - Not able to draw a full circle on canvas in JavaScript using mouse events
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM