Implement shape annotation drawing with rectangle and circle#1830
Open
michaelpixelscoder wants to merge 4 commits intocgwire:mainfrom
Open
Implement shape annotation drawing with rectangle and circle#1830michaelpixelscoder wants to merge 4 commits intocgwire:mainfrom
michaelpixelscoder wants to merge 4 commits intocgwire:mainfrom
Conversation
Contributor
|
Could you add an arrow shape also? |
Contributor
|
Hello @michaelpixelscoder, do you have any news about this PR? |
Author
|
Hi, I just made an update. I added the arrow shape, I refactored it using a custom Fabric shape. At first I was trying by composing a line and a triangle into a group, but it wasn't looking good in the code. |
Author
|
There is an issue with rectangle and circle serialization, I'm looking into it. I will have more time to work on it this week |
Contributor
|
Great! Thank you for the update! |
4be3478 to
5ab6e00
Compare
NicoPennec
pushed a commit
to NicoPennec/kitsu
that referenced
this pull request
Apr 27, 2026
- Recover the Arrow class drafted in cgwire#1830 as src/lib/arrowshape.js: extends fabric.Line with a triangular head, two endpoint controls for reshape, toObject / fromObject for round-tripping, and SVG export. Cleaned up the dead code from the PR draft. - Add attachShapeDrawing to src/lib/annotation.js: a fabric mouse:down / move / up listener bundle that drag-creates a rectangle, circle or arrow, paints a grey semi-transparent preview while dragging and finalises with a transparent fill on release. Calls back into the composable so finalised shapes flow through the same setObjectData / pushAddition pipeline as PSBrush strokes. - Extend buildReadOnlyShape to deserialise arrows. - Track currentTool ('pen' | 'rectangle' | 'circle' | 'arrow') in useSharedAnnotationCanvas and switch the canvas between isDrawingMode (PSBrush) and the shape listeners automatically. Shapes use a fixed SHAPE_STROKE_WIDTH (4) instead of the pencil bucket so the constant-thickness lines do not look heavier than the pressure-modulated pen. - Toolbar in SharedAnnotationOverlay now shows the four tool buttons (pen / rect / circle / arrow) with active styling, separated from the undo / clear / save actions by a divider. - Teach annotationMixin.addObjectToCanvas about rect / circle / arrow so the shapes guests draw render in the studio playlist and preview players too. The arrow import side-effect registers fabric.Arrow globally for the existing deserialisation paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Shape Annotation tool
The Shape Annotation tool allow the user to place some shapes (rectangle and circle) as annotation
Demo
2025-07-21_shape_annotation.mp4
TODO