vxe-pc-ui 3.14.29 → 3.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.
@@ -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
@@ -63416,21 +63416,6 @@ function calcContentWH(contList) {
63416
63416
  contentHeight: contentHeight
63417
63417
  };
63418
63418
  }
63419
- function calcCanvasWH(contentWidth, opts) {
63420
- var gap = opts.gap;
63421
- var _ref = gap ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(gap) ? gap : [gap, gap] : [],
63422
- _ref2 = _slicedToArray(_ref, 2),
63423
- _ref2$ = _ref2[0],
63424
- gapX = _ref2$ === void 0 ? 0 : _ref2$,
63425
- _ref2$2 = _ref2[1],
63426
- gapY = _ref2$2 === void 0 ? 0 : _ref2$2;
63427
- var canvasWidth = contentWidth + external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapX);
63428
- var canvasHeight = contentWidth + external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapY);
63429
- return {
63430
- canvasWidth: canvasWidth,
63431
- canvasHeight: canvasHeight
63432
- };
63433
- }
63434
63419
  function getFontConf(item, key, opts) {
63435
63420
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '');
63436
63421
  }
@@ -63438,12 +63423,12 @@ function createMarkFont(contConf, defaultFontSize, opts) {
63438
63423
  var offset = opts.offset;
63439
63424
  var text = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toValueString(contConf.textContent);
63440
63425
  var fontSize = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(getFontConf(contConf, 'fontSize', opts) || defaultFontSize) || 14;
63441
- var _ref3 = offset ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(offset) ? offset : [offset, offset] : [],
63442
- _ref4 = _slicedToArray(_ref3, 2),
63443
- _ref4$ = _ref4[0],
63444
- offsetX = _ref4$ === void 0 ? 0 : _ref4$,
63445
- _ref4$2 = _ref4[1],
63446
- offsetY = _ref4$2 === void 0 ? 0 : _ref4$2;
63426
+ var _ref = offset ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(offset) ? offset : [offset, offset] : [],
63427
+ _ref2 = _slicedToArray(_ref, 2),
63428
+ _ref2$ = _ref2[0],
63429
+ offsetX = _ref2$ === void 0 ? 0 : _ref2$,
63430
+ _ref2$2 = _ref2[1],
63431
+ offsetY = _ref2$2 === void 0 ? 0 : _ref2$2;
63447
63432
  var _calcFontWH = calcFontWH(text, fontSize),
63448
63433
  width = _calcFontWH.width,
63449
63434
  height = _calcFontWH.height;
@@ -63485,28 +63470,39 @@ function getContentUrl(content, defaultFontSize, options) {
63485
63470
  }
63486
63471
  var ctx = canvasEl.getContext('2d');
63487
63472
  if (ctx && contList.length) {
63473
+ var gap = opts.gap;
63474
+ var gapList = gap ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(gap) ? gap : [gap, gap] : [];
63475
+ var gapX = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapList[0]);
63476
+ var gapY = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(gapList[1]);
63488
63477
  var _calcContentWH = calcContentWH(contList),
63489
- contentWidth = _calcContentWH.contentWidth,
63490
- contentHeight = _calcContentWH.contentHeight;
63491
- var _calcCanvasWH = calcCanvasWH(contentWidth, opts),
63492
- canvasWidth = _calcCanvasWH.canvasWidth,
63493
- canvasHeight = _calcCanvasWH.canvasHeight;
63478
+ contentWidth = _calcContentWH.contentWidth;
63479
+ var canvasWidth = contentWidth * 2 + gapX * 2 + gapX / 2;
63480
+ var canvasHeight = contentWidth * 2 + gapY;
63494
63481
  canvasEl.width = canvasWidth;
63495
63482
  canvasEl.height = canvasHeight;
63496
- var x = (canvasWidth - contentWidth) / 2;
63497
- var y = (canvasHeight - contentHeight) / 2;
63498
- var drayX = x + contentWidth / 2;
63499
- var drayY = y + contentHeight / 2;
63483
+ var drayX = gapX / 2;
63484
+ var drayY = contentWidth + gapY / 2;
63500
63485
  ctx.save();
63501
63486
  ctx.translate(drayX, drayY);
63502
63487
  ctx.rotate(deg * Math.PI / 180);
63503
63488
  ctx.translate(-drayX, -drayY);
63504
- var offsetHeight = 0;
63489
+ var txtOffsetY = 0;
63490
+ contList.forEach(function (item) {
63491
+ drayFont(ctx, item, opts);
63492
+ var txtX = drayX;
63493
+ var txtY = drayY + txtOffsetY;
63494
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
63495
+ txtOffsetY += item.height;
63496
+ });
63497
+ var offsetX = gapX;
63498
+ var offsetY = gapY + contentWidth;
63499
+ txtOffsetY = 0;
63505
63500
  contList.forEach(function (item) {
63506
- var align = getFontConf(item, 'align', opts);
63507
63501
  drayFont(ctx, item, opts);
63508
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth);
63509
- offsetHeight += item.height;
63502
+ var txtX = drayX + offsetX;
63503
+ var txtY = drayY + txtOffsetY + offsetY;
63504
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
63505
+ txtOffsetY += item.height;
63510
63506
  });
63511
63507
  ctx.restore();
63512
63508
  resolve(canvasEl.toDataURL());