vxe-pc-ui 4.14.29 → 4.14.30

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/all.esm.js CHANGED
@@ -41699,16 +41699,6 @@ function calcContentWH(contList) {
41699
41699
  contentHeight
41700
41700
  };
41701
41701
  }
41702
- function calcCanvasWH(contentWidth, opts) {
41703
- const { gap } = opts;
41704
- const [gapX = 0, gapY = 0] = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : [];
41705
- const canvasWidth = contentWidth + XEUtils.toNumber(gapX);
41706
- const canvasHeight = contentWidth + XEUtils.toNumber(gapY);
41707
- return {
41708
- canvasWidth,
41709
- canvasHeight
41710
- };
41711
- }
41712
41702
  function getFontConf(item, key, opts) {
41713
41703
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '');
41714
41704
  }
@@ -41761,24 +41751,38 @@ function getContentUrl(content, defaultFontSize, options) {
41761
41751
  }
41762
41752
  const ctx = canvasEl.getContext('2d');
41763
41753
  if (ctx && contList.length) {
41764
- const { contentWidth, contentHeight } = calcContentWH(contList);
41765
- const { canvasWidth, canvasHeight } = calcCanvasWH(contentWidth, opts);
41754
+ const { gap } = opts;
41755
+ const gapList = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : [];
41756
+ const gapX = XEUtils.toNumber(gapList[0]);
41757
+ const gapY = XEUtils.toNumber(gapList[1]);
41758
+ const { contentWidth } = calcContentWH(contList);
41759
+ const canvasWidth = contentWidth * 2 + gapX * 2 + (gapX / 2);
41760
+ const canvasHeight = contentWidth * 2 + gapY;
41766
41761
  canvasEl.width = canvasWidth;
41767
41762
  canvasEl.height = canvasHeight;
41768
- const x = (canvasWidth - contentWidth) / 2;
41769
- const y = (canvasHeight - contentHeight) / 2;
41770
- const drayX = x + (contentWidth / 2);
41771
- const drayY = y + (contentHeight / 2);
41763
+ const drayX = (gapX / 2);
41764
+ const drayY = contentWidth + (gapY / 2);
41772
41765
  ctx.save();
41773
41766
  ctx.translate(drayX, drayY);
41774
41767
  ctx.rotate(deg * Math.PI / 180);
41775
41768
  ctx.translate(-drayX, -drayY);
41776
- let offsetHeight = 0;
41769
+ let txtOffsetY = 0;
41770
+ contList.forEach((item) => {
41771
+ drayFont(ctx, item, opts);
41772
+ const txtX = drayX;
41773
+ const txtY = drayY + txtOffsetY;
41774
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
41775
+ txtOffsetY += item.height;
41776
+ });
41777
+ const offsetX = gapX;
41778
+ const offsetY = gapY + contentWidth;
41779
+ txtOffsetY = 0;
41777
41780
  contList.forEach((item) => {
41778
- const align = getFontConf(item, 'align', opts);
41779
41781
  drayFont(ctx, item, opts);
41780
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth);
41781
- offsetHeight += item.height;
41782
+ const txtX = drayX + offsetX;
41783
+ const txtY = drayY + txtOffsetY + offsetY;
41784
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
41785
+ txtOffsetY += item.height;
41782
41786
  });
41783
41787
  ctx.restore();
41784
41788
  resolve(canvasEl.toDataURL());
@@ -52,16 +52,6 @@ function calcContentWH(contList) {
52
52
  contentHeight
53
53
  };
54
54
  }
55
- function calcCanvasWH(contentWidth, opts) {
56
- const { gap } = opts;
57
- const [gapX = 0, gapY = 0] = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : [];
58
- const canvasWidth = contentWidth + XEUtils.toNumber(gapX);
59
- const canvasHeight = contentWidth + XEUtils.toNumber(gapY);
60
- return {
61
- canvasWidth,
62
- canvasHeight
63
- };
64
- }
65
55
  function getFontConf(item, key, opts) {
66
56
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '');
67
57
  }
@@ -114,24 +104,38 @@ export function getContentUrl(content, defaultFontSize, options) {
114
104
  }
115
105
  const ctx = canvasEl.getContext('2d');
116
106
  if (ctx && contList.length) {
117
- const { contentWidth, contentHeight } = calcContentWH(contList);
118
- const { canvasWidth, canvasHeight } = calcCanvasWH(contentWidth, opts);
107
+ const { gap } = opts;
108
+ const gapList = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : [];
109
+ const gapX = XEUtils.toNumber(gapList[0]);
110
+ const gapY = XEUtils.toNumber(gapList[1]);
111
+ const { contentWidth } = calcContentWH(contList);
112
+ const canvasWidth = contentWidth * 2 + gapX * 2 + (gapX / 2);
113
+ const canvasHeight = contentWidth * 2 + gapY;
119
114
  canvasEl.width = canvasWidth;
120
115
  canvasEl.height = canvasHeight;
121
- const x = (canvasWidth - contentWidth) / 2;
122
- const y = (canvasHeight - contentHeight) / 2;
123
- const drayX = x + (contentWidth / 2);
124
- const drayY = y + (contentHeight / 2);
116
+ const drayX = (gapX / 2);
117
+ const drayY = contentWidth + (gapY / 2);
125
118
  ctx.save();
126
119
  ctx.translate(drayX, drayY);
127
120
  ctx.rotate(deg * Math.PI / 180);
128
121
  ctx.translate(-drayX, -drayY);
129
- let offsetHeight = 0;
122
+ let txtOffsetY = 0;
123
+ contList.forEach((item) => {
124
+ drayFont(ctx, item, opts);
125
+ const txtX = drayX;
126
+ const txtY = drayY + txtOffsetY;
127
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
128
+ txtOffsetY += item.height;
129
+ });
130
+ const offsetX = gapX;
131
+ const offsetY = gapY + contentWidth;
132
+ txtOffsetY = 0;
130
133
  contList.forEach((item) => {
131
- const align = getFontConf(item, 'align', opts);
132
134
  drayFont(ctx, item, opts);
133
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth);
134
- offsetHeight += item.height;
135
+ const txtX = drayX + offsetX;
136
+ const txtY = drayY + txtOffsetY + offsetY;
137
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
138
+ txtOffsetY += item.height;
135
139
  });
136
140
  ctx.restore();
137
141
  resolve(canvasEl.toDataURL());
package/lib/index.umd.js CHANGED
@@ -50807,18 +50807,6 @@ function calcContentWH(contList) {
50807
50807
  contentHeight
50808
50808
  };
50809
50809
  }
50810
- function calcCanvasWH(contentWidth, opts) {
50811
- const {
50812
- gap
50813
- } = opts;
50814
- const [gapX = 0, gapY = 0] = gap ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(gap) ? gap : [gap, gap] : [];
50815
- const canvasWidth = contentWidth + external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapX);
50816
- const canvasHeight = contentWidth + external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapY);
50817
- return {
50818
- canvasWidth,
50819
- canvasHeight
50820
- };
50821
- }
50822
50810
  function getFontConf(item, key, opts) {
50823
50811
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '');
50824
50812
  }
@@ -50874,29 +50862,41 @@ function getContentUrl(content, defaultFontSize, options) {
50874
50862
  const ctx = canvasEl.getContext('2d');
50875
50863
  if (ctx && contList.length) {
50876
50864
  const {
50877
- contentWidth,
50878
- contentHeight
50879
- } = calcContentWH(contList);
50865
+ gap
50866
+ } = opts;
50867
+ const gapList = gap ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(gap) ? gap : [gap, gap] : [];
50868
+ const gapX = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapList[0]);
50869
+ const gapY = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapList[1]);
50880
50870
  const {
50881
- canvasWidth,
50882
- canvasHeight
50883
- } = calcCanvasWH(contentWidth, opts);
50871
+ contentWidth
50872
+ } = calcContentWH(contList);
50873
+ const canvasWidth = contentWidth * 2 + gapX * 2 + gapX / 2;
50874
+ const canvasHeight = contentWidth * 2 + gapY;
50884
50875
  canvasEl.width = canvasWidth;
50885
50876
  canvasEl.height = canvasHeight;
50886
- const x = (canvasWidth - contentWidth) / 2;
50887
- const y = (canvasHeight - contentHeight) / 2;
50888
- const drayX = x + contentWidth / 2;
50889
- const drayY = y + contentHeight / 2;
50877
+ const drayX = gapX / 2;
50878
+ const drayY = contentWidth + gapY / 2;
50890
50879
  ctx.save();
50891
50880
  ctx.translate(drayX, drayY);
50892
50881
  ctx.rotate(deg * Math.PI / 180);
50893
50882
  ctx.translate(-drayX, -drayY);
50894
- let offsetHeight = 0;
50883
+ let txtOffsetY = 0;
50884
+ contList.forEach(item => {
50885
+ drayFont(ctx, item, opts);
50886
+ const txtX = drayX;
50887
+ const txtY = drayY + txtOffsetY;
50888
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
50889
+ txtOffsetY += item.height;
50890
+ });
50891
+ const offsetX = gapX;
50892
+ const offsetY = gapY + contentWidth;
50893
+ txtOffsetY = 0;
50895
50894
  contList.forEach(item => {
50896
- const align = getFontConf(item, 'align', opts);
50897
50895
  drayFont(ctx, item, opts);
50898
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth);
50899
- offsetHeight += item.height;
50896
+ const txtX = drayX + offsetX;
50897
+ const txtY = drayY + txtOffsetY + offsetY;
50898
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
50899
+ txtOffsetY += item.height;
50900
50900
  });
50901
50901
  ctx.restore();
50902
50902
  resolve(canvasEl.toDataURL());