Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shape on double click #10

Open
pmelchior opened this issue May 3, 2013 · 1 comment
Open

Add shape on double click #10

pmelchior opened this issue May 3, 2013 · 1 comment

Comments

@pmelchior
Copy link

Hi Amit. I'd like to give user the ability to mark an object in an image, ideally by double-clicking at its location, which should then draw a circle around it. I've added this event handler to the API after line 250 of webfits-canvas.js:

this.canvas.ondblclick = function(e) {
        var ctx = _this.canvas.getContext('2d');
        ctx.beginPath();
        ctx.arc(_this.xMouseDown, _this.yMouseDown, 80, 0, 2*Math.PI, true);
        ctx.lineWidth=2;
        ctx.strokeStyle='#FF0000';
        ctx.stroke();
        ctx.closePath();
        return _this.draw();
      };

I verified that the double-click event triggers this function, but I don't see any effect on the canvas. I'm aware that's more an issue of my limited canvas knowledge, but if you have an idea to make this work, it might be useful for other webfits applications, too.

@kapadia
Copy link
Member

kapadia commented May 7, 2013

Peter, it might be best to add another canvas as an overlay. This way you keep the image separate from the markings, and don't have to deal with the internals of the webfits library.

In the future I intend to offer methods to facilitate this functionality, but hard to tell you when ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants