layerchart
layerchart copied to clipboard
Add `TextRect` component to easily add backgrounds to `Text` components
Would be very helpful when using Svg and Canvas layers to easily add a Rect as a background behind a Text. Getting the dimensions (and support a padding attribute) will take some thought.
This could also be directly integrated into Text as:
<Text background="...">, <Text bg="...">, etc
Since we already get word/line width in Text we should able able to leverage this to create the width of the bounding box.
- getBBBox() (SVG)
- measureText() / TextMetrics (Canvas)
Currently getStringWidth() uses getComputedTextLength() but might be better to get the bounding box with one of the aforementioned.
See also this canvas StackOverflow answer and SVG example