fix(study): legacy stroke 도 첫 draw 시점에 refW/refH 자동 fix

이전 commit (33060e9) 의 drawStrokeScaled 가 refW 없는 legacy stroke 는 1배로
그려서 fix 효과가 새 stroke 에만 적용. 사용자 환경의 기존 stroke 129개에는 비례
보정 안 됐음.

Fix: drawStrokeScaled 안에서 refW 없으면 *첫 draw 시점*의 cssWidth/cssHeight 로
자동 set. 그 후 cssWidth 변화 (button click 의 layout shift / 창 크기 조정) 시
ctx.scale 비례 적용. load 시점 cssWidth = 사용자가 그 strokes 를 보는 환경의
dimension 이므로 일관된 기준.

→ 기존 세션 그대로 두어도 button click / 창 이동 시 stroke 위치 보존.
This commit is contained in:
Hyungi Ahn
2026-04-27 14:36:49 +09:00
parent 33060e9358
commit ba04955ee5
@@ -239,10 +239,13 @@
}
// stroke 의 refW/refH 와 현재 cssWidth/cssHeight 비례로 ctx.scale 적용 후 그림.
// refW 없는 (legacy) stroke 는 현재 cssWidth/cssHeight 기준 = 1배 (load 시점 기준).
// legacy stroke (refW 없음) 은 *첫 draw 시점* 의 cssWidth/cssHeight 로 fix —
// 그 후 cssWidth 변화 (button click 의 layout shift / 창 크기 조정) 시 비례 유지.
function drawStrokeScaled(ctx: CanvasRenderingContext2D, s: Stroke, isInflight: boolean) {
const sx = s.refW && s.refW > 0 ? cssWidth / s.refW : 1;
const sy = s.refH && s.refH > 0 ? cssHeight / s.refH : 1;
if (!s.refW || s.refW <= 0) s.refW = cssWidth;
if (!s.refH || s.refH <= 0) s.refH = cssHeight;
const sx = cssWidth / s.refW;
const sy = cssHeight / s.refH;
if (sx === 1 && sy === 1) {
drawStroke(ctx, s, isInflight);
return;