Added
drawing_mode="labeled_rect": a rect tool that stamps every box drawn
with a label chip. Newlabel: str = ""parameter -- Python supplies the
current label, and each box drawn is stamped with whatever it was at the
time; changinglabelbetween draws does not relabel boxes already on the
canvas.label=""(the default) draws a box with no chip. Passing a
non-emptylabelin any otherdrawing_moderaisesValueError.
The chip sits above the box's top-left corner at a constant screen size
regardless of the box's scale, and flips inside the box near the top of
the canvas. Its colour is derived fromstroke_color, with the text
colour auto-picked for contrast; its font size reusesfont_size.
Labeled boxes are always axis-aligned (no rotation handle) and are
excluded from the toolbar edit toggle's point editing.- Relabeling: with the toolbar's edit toggle on, click an
already-selected labeled box a second time to edit its label through a
transient text field -- the same gesture that re-enters anITextor
descends into point editing. One undo entry per relabel. CanvasResult.boxes: every labeled box on the canvas as
{label, left, top, width, height}dicts, in canvas pixels, with the
scaleX/scaleYcorrection already applied.CanvasResult.boxes_in_image_space:boxesconverted into
background_image's source pixels.Nonewhen there is no background
image.CanvasResult.background_fit: the background image's natural size
and applied scale/offset.Nonewhen there is no background image.boxes_to_drawing(): a module-level function building an
initial_drawingfromCanvasResult.boxes-shaped dicts -- the exact
inverse ofboxes.font_sizenow also applies todrawing_mode="labeled_rect"'s chip text,
in addition todrawing_mode="text". No behaviour change for existing
calls.
A drawing containing a labeled box needs this version or later to load --
on an earlier version (or any other app embedding Fabric.js directly
without this component's class registered), loading it fails entirely and
none of the canvas's objects appear, not just the labeled ones.