refactor: extract TextCore shared text engine + sticky width-only resize

TextCore.ts: shared text rendering with dirty-check caching, zoom-bucket
resolution, and optional word-wrap. TextSprite and StickySprite now
compose TextCore instead of duplicating text logic.

Sticky resize now bakes width only (fontSize stays stable), so dragging
a sticky wider/narrower reflows text with auto-adjusted height — like
a resizable text box.
This commit is contained in:
Hiren Kangad
2026-03-12 23:53:06 +05:30
parent d9c1f4c600
commit a20cab3fcd
4 changed files with 200 additions and 127 deletions
+2 -2
View File
@@ -231,9 +231,9 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
item.displayObject.scale.set(d.sx, d.sy);
} else if (item.type === 'sticky') {
const d = item.data as any;
// Scale card width and fontSize, then reset sx/sy so text re-rasterizes crisp
// Bake width only — text re-wraps and height auto-adjusts.
// fontSize stays stable so the card acts like a resizable text box.
d.w = Math.round(d.w * absSx);
d.fontSize = Math.round((d.fontSize || 14) * ((absSx + absSy) / 2));
d.sx = item.data.sx > 0 ? 1 : -1;
d.sy = item.data.sy > 0 ? 1 : -1;
if (item.displayObject instanceof StickySprite) {