@leafer-draw/node 1.5.1 → 1.5.3

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.
package/dist/node.esm.js CHANGED
@@ -692,16 +692,20 @@ Object.assign(Creator, {
692
692
  Platform.layout = Layouter.fullLayout;
693
693
 
694
694
  function fillText(ui, canvas) {
695
- let row;
696
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
695
+ let row, data = ui.__.__textDrawData;
696
+ const { rows, decorationY } = data;
697
697
  for (let i = 0, len = rows.length; i < len; i++) {
698
698
  row = rows[i];
699
699
  if (row.text)
700
700
  canvas.fillText(row.text, row.x, row.y);
701
701
  else if (row.data)
702
702
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
703
- if (decorationY)
704
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
703
+ }
704
+ if (decorationY) {
705
+ const { decorationColor, decorationHeight } = data;
706
+ if (decorationColor)
707
+ canvas.fillStyle = decorationColor;
708
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
705
709
  }
706
710
  }
707
711
 
@@ -772,16 +776,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
772
776
  out.recycle(ui.__nowWorld);
773
777
  }
774
778
  function drawTextStroke(ui, canvas) {
775
- let row;
776
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
779
+ let row, data = ui.__.__textDrawData;
780
+ const { rows, decorationY } = data;
777
781
  for (let i = 0, len = rows.length; i < len; i++) {
778
782
  row = rows[i];
779
783
  if (row.text)
780
784
  canvas.strokeText(row.text, row.x, row.y);
781
785
  else if (row.data)
782
786
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
783
- if (decorationY)
784
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
787
+ }
788
+ if (decorationY) {
789
+ const { decorationHeight } = data;
790
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
785
791
  }
786
792
  }
787
793
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -1347,6 +1353,8 @@ function recycleImage(attrName, data) {
1347
1353
  }
1348
1354
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
1349
1355
  }
1356
+ else
1357
+ paints[i].style = null;
1350
1358
  }
1351
1359
  }
1352
1360
  return recycleMap;
@@ -2079,14 +2087,25 @@ function toTextChar(row) {
2079
2087
  }
2080
2088
 
2081
2089
  function decorationText(drawData, style) {
2082
- const { fontSize } = style;
2090
+ let type;
2091
+ const { fontSize, textDecoration } = style;
2083
2092
  drawData.decorationHeight = fontSize / 11;
2084
- switch (style.textDecoration) {
2093
+ if (typeof textDecoration === 'object') {
2094
+ type = textDecoration.type;
2095
+ if (textDecoration.color)
2096
+ drawData.decorationColor = ColorConvert.string(textDecoration.color);
2097
+ }
2098
+ else
2099
+ type = textDecoration;
2100
+ switch (type) {
2085
2101
  case 'under':
2086
- drawData.decorationY = fontSize * 0.15;
2102
+ drawData.decorationY = [fontSize * 0.15];
2087
2103
  break;
2088
2104
  case 'delete':
2089
- drawData.decorationY = -fontSize * 0.35;
2105
+ drawData.decorationY = [-fontSize * 0.35];
2106
+ break;
2107
+ case 'under-delete':
2108
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2090
2109
  }
2091
2110
  }
2092
2111