-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/clamp to image #221
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a new feature allow_annotations_outside_image that constrains annotations to remain within image boundaries. When disabled, the feature prevents users from creating or moving annotations outside the image bounds and provides visual feedback through screen shaking when such actions are attempted.
Key changes:
- Added the
allow_annotations_outside_imageconfiguration option (defaults totruefor backward compatibility) - Implemented annotation clamping logic that constrains points to image boundaries
- Added screen shake feedback when users attempt invalid operations outside image bounds
Reviewed Changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/version.js | Version bump from 0.17.0 to 0.18.0 |
| package.json | Version bump in package configuration |
| src/configuration.ts | Added new configuration option allow_annotations_outside_image |
| src/geometric_utils.ts | Added utility functions for point clamping and boundary checking |
| src/annotation.ts | Added fit_to_image_bounds method to annotation class |
| src/index.js | Core implementation of clamping logic and screen shake feedback |
| src/initializer.ts | Added initialization logic to clamp existing annotations |
| src/toolbox.ts | Added annotation clamping during submission |
| demo files | Updated demo configurations to test the new feature |
| api_spec.md | Added documentation for the new configuration option |
| CHANGELOG.md | Documented the new feature |
Comments suppressed due to low confidence (1)
src/index.js:5058
- The
is_shakingflag is set to false immediately after starting the shake animation, which defeats the purpose of preventing multiple simultaneous shake animations. This should be set to false in the completion callback of the shake interval.
// If the move wasn't allowed in the first place, we don't want to redo it
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… into feature/clamp-to-image
joshua-dean
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the shaking.
Just a couple of docstring changes.
It might be good to attach the clamping functions to the ULabel object somewhere so that other people can call them if desired (see #222).
joshua-dean
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Fair point, I'll noodle on what seems like the best way to do so |
allow_annotations_outside_image
Description
allow_annotations_outside_imagearg which defaults totrue.false, new annotations will be limited to points within the image, and attempts to move annotations outside the image will bounce back.PR Checklist
package.jsonhas been bumped since last releasepackage.jsonandsrc/version.jsnpm installandnpm run buildAFTER bumping the version numberapi_spec.md)changelog.mdBreaking API Changes
No. Old behavior is still the default.