Skip to content

Implement shape annotation drawing with rectangle and circle#1830

Open
michaelpixelscoder wants to merge 4 commits intocgwire:mainfrom
Pixels-Coder:improve_annotation
Open

Implement shape annotation drawing with rectangle and circle#1830
michaelpixelscoder wants to merge 4 commits intocgwire:mainfrom
Pixels-Coder:improve_annotation

Conversation

@michaelpixelscoder
Copy link
Copy Markdown

@michaelpixelscoder michaelpixelscoder commented Jul 21, 2025

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

  • Implement shape tool button
  • Shape selector
  • Color Picker
  • Add Arrow Shape
  • Stroke Width Picker
  • Serialization

@frankrousseau
Copy link
Copy Markdown
Contributor

Could you add an arrow shape also?

@frankrousseau
Copy link
Copy Markdown
Contributor

Hello @michaelpixelscoder, do you have any news about this PR?

@michaelpixelscoder
Copy link
Copy Markdown
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.

@michaelpixelscoder
Copy link
Copy Markdown
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

@frankrousseau
Copy link
Copy Markdown
Contributor

Great! Thank you for the update!

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

Successfully merging this pull request may close these issues.

3 participants