embroidery-qc-image 1.0.28 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAiKjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAofD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmHvD,CAAC;AAy9CF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAuBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAuBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAiKjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAofD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmHvD,CAAC;AAo9CF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAuBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAuBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -569,21 +569,21 @@ const renderEmbroideryCanvas = (canvas, config, canvasSize, imageRefs) => {
569
569
  // Tìm scaleFactor tối ưu bằng binary search trong [0, 1]
570
570
  const maxIterations = 12;
571
571
  const epsilon = 0.001; // độ chính xác cho khoảng cách low-high
572
- const contentHeight = canvas.height - LAYOUT.PADDING;
572
+ const contentHeight = canvas.height;
573
573
  let low = 0;
574
574
  let high = 1;
575
575
  for (let i = 0; i < maxIterations; i++) {
576
576
  const testScale = (low + high) / 2;
577
577
  // (Không cần clear measureCanvas vì chỉ dùng để đo chiều cao, nhưng làm sạch cho dễ debug)
578
578
  measureCtx.clearRect(0, 0, measureCanvas.width, measureCanvas.height);
579
- // Đo warning & message đúng theo renderWarning, không cộng padding ở đây
580
- let testMeasureY = 0;
579
+ // Đo warning & message đúng theo renderWarning, bao gồm padding
580
+ let testMeasureY = LAYOUT.PADDING;
581
581
  if (config.warning_message) {
582
- const testWarningHeight = renderWarning(measureCtx, measureCanvas, config.warning_message, testScale);
582
+ const testWarningHeight = renderWarning(measureCtx, measureCanvas, config.warning_message, testScale, testMeasureY);
583
583
  testMeasureY += testWarningHeight;
584
584
  }
585
585
  if (config.message) {
586
- const testMessageHeight = renderWarning(measureCtx, measureCanvas, config.message, testScale, 0, "", DEFAULT_ERROR_COLOR);
586
+ const testMessageHeight = renderWarning(measureCtx, measureCanvas, config.message, testScale, testMeasureY, "", DEFAULT_ERROR_COLOR);
587
587
  testMeasureY += testMessageHeight;
588
588
  }
589
589
  // Đo lại chiều cao của các sides với scaleFactor, tiếp nối sau warning/message
@@ -591,7 +591,7 @@ const renderEmbroideryCanvas = (canvas, config, canvasSize, imageRefs) => {
591
591
  const sideHeight = renderSide(measureCtx, side, testMeasureY, canvas.width, canvas.height, testScale, imageRefs, mockupBounds);
592
592
  testMeasureY += sideHeight + measureSpacing * testScale;
593
593
  });
594
- // Tổng chiều cao content (không gồm padding)
594
+ // Tổng chiều cao content
595
595
  const totalHeight = testMeasureY;
596
596
  if (totalHeight > contentHeight) {
597
597
  // Content đang cao hơn vùng cho phép -> giảm scale
@@ -607,23 +607,17 @@ const renderEmbroideryCanvas = (canvas, config, canvasSize, imageRefs) => {
607
607
  }
608
608
  const scaleFactor = low;
609
609
  drawMockup(ctx, canvas, imageRefs);
610
+ // Calculate currentY: padding top + actual warning & message height (no spacing)
611
+ let currentY = LAYOUT.PADDING;
610
612
  // Render warning & message with scaleFactor and get actual heights
611
- let actualWarningHeight = 0;
612
- let actualMessageHeight = 0;
613
613
  if (config.warning_message) {
614
- actualWarningHeight = renderWarning(ctx, canvas, config.warning_message, scaleFactor);
614
+ const actualWarningHeight = renderWarning(ctx, canvas, config.warning_message, scaleFactor, currentY);
615
+ currentY += actualWarningHeight;
615
616
  }
616
617
  if (config.message) {
617
- actualMessageHeight = renderWarning(ctx, canvas, config.message, scaleFactor, actualWarningHeight, "", // message: không cần prefix "Note"
618
+ const actualMessageHeight = renderWarning(ctx, canvas, config.message, scaleFactor, currentY, "", // message: không cần prefix "Note"
618
619
  DEFAULT_ERROR_COLOR // message: hiển thị màu đỏ
619
620
  );
620
- }
621
- // Calculate currentY: padding top + actual warning & message height (no spacing)
622
- let currentY = LAYOUT.PADDING;
623
- if (config.warning_message && actualWarningHeight > 0) {
624
- currentY += actualWarningHeight;
625
- }
626
- if (config.message && actualMessageHeight > 0) {
627
621
  currentY += actualMessageHeight;
628
622
  }
629
623
  config.sides.forEach((side) => {
@@ -696,9 +690,8 @@ const renderWarning = (ctx, canvas, message, scaleFactor = 1, offsetY = 0, prefi
696
690
  lines = buildWrappedLines(ctx, sanitizedMessage, maxWidth);
697
691
  longestLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
698
692
  }
699
- const startY = LAYOUT.PADDING * scaleFactor + offsetY;
700
693
  lines.forEach((line, index) => {
701
- const y = startY + index * lineHeight;
694
+ const y = offsetY + index * lineHeight;
702
695
  ctx.fillText(line, leftX, y);
703
696
  });
704
697
  ctx.restore();