Skip to content

Conversation

@TrevorBurgoyne
Copy link
Member

@TrevorBurgoyne TrevorBurgoyne commented Jul 15, 2025

allow_annotations_outside_image

Description

  • Closes Restrict Annotations to Image Bounds #219
  • add allow_annotations_outside_image arg which defaults to true.
    • when set to false, new annotations will be limited to points within the image, and attempts to move annotations outside the image will bounce back.

PR Checklist

  • Merged latest main
  • Version number in package.json has been bumped since last release
  • Version numbers match between package package.json and src/version.js
  • Ran npm install and npm run build AFTER bumping the version number
  • Updated documentation if necessary (currently just in api_spec.md)
  • Added changes to changelog.md

Breaking API Changes

No. Old behavior is still the default.

Base automatically changed from feature/size-mode to main July 15, 2025 19:13
@TrevorBurgoyne TrevorBurgoyne added the enhancement New feature or request label Jul 21, 2025
@TrevorBurgoyne TrevorBurgoyne marked this pull request as ready for review July 21, 2025 19:00
Copy link
Contributor

Copilot AI left a 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_image configuration option (defaults to true for 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_shaking flag 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

TrevorBurgoyne and others added 4 commits July 21, 2025 14:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@joshua-dean joshua-dean left a 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).

Copy link
Collaborator

@joshua-dean joshua-dean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@TrevorBurgoyne
Copy link
Member Author

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).

Fair point, I'll noodle on what seems like the best way to do so

@TrevorBurgoyne TrevorBurgoyne merged commit 585a97c into main Jul 22, 2025
1 check passed
@TrevorBurgoyne TrevorBurgoyne deleted the feature/clamp-to-image branch July 22, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restrict Annotations to Image Bounds

3 participants