@threedddplus/logoeditor 0.0.112-2 → 0.0.112-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.
@@ -8845,6 +8845,7 @@ var Rightmenu = function Rightmenu() {
8845
8845
  }
8846
8846
  var newTextPath = new fabric.fabric.Path(p.output());
8847
8847
  // add new textPath
8848
+ console.log("---<", textSelected, textSelected.width, textSelected.height);
8848
8849
  canvas.add(newTextPath);
8849
8850
  newTextPath['pathData'] = textSelected.pathData;
8850
8851
  newTextPath['colorFill'] = textSelected.colorFill;
@@ -8863,16 +8864,18 @@ var Rightmenu = function Rightmenu() {
8863
8864
  newTextPath['textAlign'] = textSelected.textAlign;
8864
8865
  newTextPath['fontStyle'] = textSelected.fontStyle;
8865
8866
  newTextPath['text'] = textSelected.text;
8867
+ //@ts-ignore
8868
+ var dims = newTextPath._calcDimensions();
8866
8869
  // Set the same position scale matching with existing text
8867
8870
  newTextPath.left = textSelected.left;
8868
8871
  newTextPath.top = textSelected.top;
8869
8872
  newTextPath.width = textSelected.width;
8870
8873
  newTextPath.height = textSelected.height;
8871
- newTextPath.scaleX = textSelected.scaleX;
8872
- newTextPath.scaleY = textSelected.scaleY;
8874
+ newTextPath.scaleX = textSelected.scaleX * (textSelected.width / dims.width);
8875
+ newTextPath.scaleY = textSelected.scaleY * (textSelected.width / dims.width);
8873
8876
  newTextPath.setCoords();
8874
8877
  //@ts-ignore
8875
- var dims = newTextPath._calcDimensions();
8878
+ // let dims = newTextPath._calcDimensions();
8876
8879
  newTextPath.width = dims.width;
8877
8880
  newTextPath.height = dims.height;
8878
8881
  // delete the text object
@@ -8913,7 +8916,7 @@ var Rightmenu = function Rightmenu() {
8913
8916
  };
8914
8917
  var textShapeChange = /*#__PURE__*/function () {
8915
8918
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e, textChange, fontSize, charSpacing, strokeWidth, fontWeight, textAlign, fontStyle) {
8916
- var pathData, p, shapeType, text, _text, fabricPath, dims, newTextPath, activeObj, _dims;
8919
+ var pathData, p, shapeType, text, _text, fabricPath, dims, newTextPath, _dims, activeObj;
8917
8920
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8918
8921
  while (1) switch (_context2.prev = _context2.next) {
8919
8922
  case 0:
@@ -9003,6 +9006,7 @@ var Rightmenu = function Rightmenu() {
9003
9006
  colorFill: textSelected.colorFill,
9004
9007
  fontWeight: fontWeight
9005
9008
  });
9009
+ // let dims = fabricPath._calcDimensions();
9006
9010
  text.left = textSelected.left;
9007
9011
  text.top = textSelected.top;
9008
9012
  text.width = textSelected.width;
@@ -9065,10 +9069,10 @@ var Rightmenu = function Rightmenu() {
9065
9069
  });
9066
9070
  _text.left = textSelected.left;
9067
9071
  _text.top = textSelected.top;
9068
- _text.width = _text.getBoundingRect().width;
9069
- _text.height = _text.getBoundingRect().height;
9070
- _text.scaleX = textSelected.scaleX;
9071
- _text.scaleY = textSelected.scaleY;
9072
+ _text.scaleX = textSelected.scaleX * (textSelected.width / _text.width);
9073
+ _text.scaleY = textSelected.scaleY * (textSelected.width / _text.width);
9074
+ window["textObj"] = _text;
9075
+ _text.setCoords();
9072
9076
  _text.id = textSelected.id;
9073
9077
  // delete the active text object
9074
9078
  canvas.remove(textSelected);
@@ -9161,16 +9165,15 @@ var Rightmenu = function Rightmenu() {
9161
9165
  fabricPath['fontStyle'] = textSelected.fontStyle;
9162
9166
  fabricPath['text'] = textSelected.text;
9163
9167
  fabricPath['id'] = textSelected.id;
9164
- // Set the same position scale matching with existing text
9168
+ //@ts-ignore
9169
+ dims = fabricPath._calcDimensions(); // Set the same position scale matching with existing text
9165
9170
  fabricPath.left = textSelected.left;
9166
9171
  fabricPath.top = textSelected.top;
9167
9172
  fabricPath.width = textSelected.width;
9168
9173
  fabricPath.height = textSelected.height;
9169
- fabricPath.scaleX = textSelected.scaleX;
9170
- fabricPath.scaleY = textSelected.scaleY;
9174
+ fabricPath.scaleX = textSelected.scaleX * (textSelected.width / dims.width);
9175
+ fabricPath.scaleY = textSelected.scaleY * (textSelected.width / dims.width);
9171
9176
  fabricPath.setCoords();
9172
- //@ts-ignore
9173
- dims = fabricPath._calcDimensions();
9174
9177
  fabricPath.width = dims.width;
9175
9178
  fabricPath.height = dims.height;
9176
9179
  // var sel = new fabric.ActiveSelection(fabricPath, { canvas: canvas });
@@ -9210,8 +9213,10 @@ var Rightmenu = function Rightmenu() {
9210
9213
  newTextPath['top'] = textSelected.top;
9211
9214
  newTextPath['width'] = textSelected.width;
9212
9215
  newTextPath['height'] = textSelected.height;
9213
- newTextPath['scaleX'] = textSelected.scaleX;
9214
- newTextPath['scaleY'] = textSelected.scaleY;
9216
+ //@ts-ignore
9217
+ _dims = newTextPath._calcDimensions();
9218
+ newTextPath['scaleX'] = textSelected.scaleX * (textSelected.width / _dims.width);
9219
+ newTextPath['scaleY'] = textSelected.scaleY * (textSelected.width / _dims.width);
9215
9220
  newTextPath['id'] = textSelected.id;
9216
9221
  // delete the active text object
9217
9222
  activeObj = canvas.getActiveObject();
@@ -9226,8 +9231,6 @@ var Rightmenu = function Rightmenu() {
9226
9231
  activeSelection: newTextPath
9227
9232
  });
9228
9233
  newTextPath.setCoords();
9229
- //@ts-ignore
9230
- _dims = newTextPath._calcDimensions();
9231
9234
  newTextPath.width = _dims.width;
9232
9235
  newTextPath.height = _dims.height;
9233
9236
  canvas.renderAll();
@@ -9236,29 +9239,7 @@ var Rightmenu = function Rightmenu() {
9236
9239
  updateStoreAllObject(newTextPath);
9237
9240
  }
9238
9241
  canvas.renderAll();
9239
- // setTimeout(() => {
9240
- // reduceFontSize();
9241
- // }, 500);
9242
9242
  reduceFontSize();
9243
- // canvas.renderAll();
9244
- // let brNew = use3dddPlus.getState().activeSelection.getBoundingRect();
9245
- // while (
9246
- // Math.ceil(brNew.width + brNew.left + 45) >= Math.floor(canvas.width) ||
9247
- // Math.ceil(brNew.height + brNew.top + 10) >= Math.floor(canvas.height) ||
9248
- // Math.ceil(brNew.left) < 0 ||
9249
- // Math.ceil(brNew.top) < 0
9250
- // ) {
9251
- // textSelected.set('fontSize', textSelected.fontSize - 0.1);
9252
- // canvas.remove(canvas.getActiveObject());
9253
- // await textShapeChange(textSelected.shapeType, true);
9254
- // const activeObj = canvas.getActiveObject();
9255
- // brNew.left = activeObj.left;
9256
- // brNew.width = activeObj.width;
9257
- // brNew.top = activeObj.top;
9258
- // brNew.height = activeObj.height;
9259
- // textSelected.setCoords();
9260
- // canvas.renderAll();
9261
- // }
9262
9243
  case 103:
9263
9244
  case "end":
9264
9245
  return _context2.stop();
@@ -9304,41 +9285,6 @@ var Rightmenu = function Rightmenu() {
9304
9285
  return;
9305
9286
  }
9306
9287
  };
9307
- /*
9308
- const reduceFontSize = async () => {
9309
- let brNew = textSelected.getBoundingRect();
9310
- let canvasWidth = 0;
9311
- let canvasHeight = 0;
9312
- if (textSelected && textSelected.canvas && textSelected.canvas.width) {
9313
- canvasWidth = textSelected.canvas.width;
9314
- canvasHeight = textSelected.canvas.height;
9315
- } else {
9316
- canvasWidth = canvas.width;
9317
- canvasHeight = canvas.height;
9318
- }
9319
- while (
9320
- Math.ceil(brNew.width + brNew.left + 45) > Math.floor(canvasWidth) ||
9321
- Math.ceil(brNew.height + brNew.top + 10) > Math.floor(canvasHeight) ||
9322
- Math.ceil(brNew.left) < 0 ||
9323
- Math.ceil(brNew.top) < 0
9324
- ) {
9325
- textSelected.set('fontSize', textSelected.fontSize - 0.1);
9326
- if (currentSelection === 'path') {
9327
- await textShapeChange(textSelected.shapeType, true);
9328
- canvas.renderAll();
9329
- const activeObj = canvas.getActiveObject();
9330
- brNew.left = activeObj.left;
9331
- brNew.width = activeObj.width;
9332
- brNew.top = activeObj.top;
9333
- brNew.height = activeObj.height;
9334
- } else {
9335
- brNew = textSelected.getBoundingRect();
9336
- }
9337
- textSelected.setCoords();
9338
- // canvas.renderAll();
9339
- }
9340
- };
9341
- */
9342
9288
  var reduceFontSize = /*#__PURE__*/function () {
9343
9289
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
9344
9290
  var brNew, canvasWidth, canvasHeight, _activeObj;