Coder Social home page Coder Social logo

Comments (6)

rsimon avatar rsimon commented on May 21, 2024

I love that design! Yes, it's possible to do this in principle. What would be needed is an extra SVG path element that serves as mask. (See here for how to use path to create holes.)

The code that handles the drawing while dragging a new box in Annotorious is here:
https://github.com/recogito/annotorious/blob/master/src/tools/rectangle/RubberbandRect.js

You'd basically just need to add another shape in addition to this.shape (e.g. called this.mask) for the masking path, and update it along with this.shape.

Likewise, the code that handles the drawing for editing an existing shape (=the state in your screenshot above) is here:
https://github.com/recogito/annotorious/blob/master/src/tools/rectangle/EditableRect.js

Steps would need to be repeated there (or, better, of course, shared through some common base function.)

Last but not least, this should probably made optional through some kind of config parameter that users can set outside from the API. But that would be merely a bit of plumbing.

A pull request for this would be great! Let me know if you're interested in giving this a try.

from annotorious.

rsimon avatar rsimon commented on May 21, 2024

Just a quick update: I started playing with this and it seems to work pretty well. Will need to find some time to cleanly implement this, but it’s definitely going to come as a feature.

from annotorious.

dosstx avatar dosstx commented on May 21, 2024

Sorry I didn't respond sooner, but we have been busy with a newborn baby. I just wanted to let you know that I appreciate your update and I can't wait to grab the latest version of this plugin! Thanks again.

from annotorious.

rsimon avatar rsimon commented on May 21, 2024

I just published a new release & includes the mask feature. Two caveats:

  • per default, the mask is hidden to keep things consistent with the previous versions for now
  • it's only available for rectangle selection for now, but not yet for polygons

To switch it on: the mask is an extra SVG path element with CSS class a9s-selection-mask. Just apply a style override of your choice, e.g.

.a9s-selection-mask {
  fill: rgba(0, 0, 0, 0.6) !important;
}

from annotorious.

rsimon avatar rsimon commented on May 21, 2024

The feature is now available in the latest release and a bit of documentation + an example is available here:

https://recogito.github.io/guides/customizing-appearance/

It's not 100% as pixel perfect as in your example. (The annotation outline is centered on the mask hole, rather than aligned with it. Perhaps there are SVG experts out there who have an idea if and how this can be tweaked.)

from annotorious.

dosstx avatar dosstx commented on May 21, 2024

Just wanted to report that this works excellent! Looks really good, too! Thank you!

from annotorious.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.