0

I am trying to draw shapes on canvas using mouse events in 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? I am not getting any idea of how to draw shapes on canvas in JCanvas using mouseevents. Can you please give a basic example of using mouse events to draw shapes in jcanvas.

Thanks in advance.

akshay202
  • 586
  • 1
  • 5
  • 23
user3188826
  • 53
  • 1
  • 2
  • 8

1 Answers1

0

Have you tried to copy what is being done here:

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);
JF it
  • 2,403
  • 3
  • 20
  • 30