@threedddplus/logoeditor 0.0.66 → 0.0.67

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.
@@ -2412,15 +2412,45 @@ var fabricSlice = function fabricSlice(set, get) {
2412
2412
  clonedObj.canvas = get().fabricCanvas;
2413
2413
  clonedObj.forEachObject(function (obj, index) {
2414
2414
  obj.colorFill = activeObj._objects[index].colorFill;
2415
+ // copy all path text data & clone text props as well(text with shapes applied)
2416
+ if (activeObj.type === 'path' && activeObj.pathData !== undefined) {
2417
+ obj.pathData = activeObj.pathData;
2418
+ obj.shapeSize = activeObj.shapeSize;
2419
+ obj.shapeType = activeObj.shapeType;
2420
+ obj.fontFamily = activeObj.fontFamily;
2421
+ obj.fontWeight = activeObj.fontWeight;
2422
+ obj.fontSize = activeObj.fontSize;
2423
+ obj.charSpacing = activeObj.charSpacing;
2424
+ obj.textAlign = activeObj.textAlign;
2425
+ obj.fontStyle = activeObj.fontStyle;
2426
+ obj.text = activeObj.text;
2427
+ }
2415
2428
  get().fabricCanvas.add(obj);
2416
2429
  });
2417
2430
  clonedObj.setCoords();
2418
2431
  } else {
2419
2432
  clonedObj.colorFill = activeObj.colorFill;
2433
+ // copy all path text data & clone text props as well(text with shapes applied)
2434
+ if (activeObj.type === 'path' && activeObj.pathData !== undefined) {
2435
+ clonedObj.pathData = activeObj.pathData;
2436
+ clonedObj.shapeSize = activeObj.shapeSize;
2437
+ clonedObj.shapeType = activeObj.shapeType;
2438
+ clonedObj.fontFamily = activeObj.fontFamily;
2439
+ clonedObj.fontWeight = activeObj.fontWeight;
2440
+ clonedObj.fontSize = activeObj.fontSize;
2441
+ clonedObj.charSpacing = activeObj.charSpacing;
2442
+ clonedObj.textAlign = activeObj.textAlign;
2443
+ clonedObj.fontStyle = activeObj.fontStyle;
2444
+ clonedObj.text = activeObj.text;
2445
+ }
2420
2446
  get().fabricCanvas.add(clonedObj);
2421
2447
  }
2422
2448
  clipboard.top += 20;
2423
2449
  clipboard.left += 20;
2450
+ if (activeObj && activeObj.shapeType && activeObj.shapeType.length > 0) {
2451
+ clonedObj.shapeType = activeObj.shapeType;
2452
+ clonedObj.shapeSize = activeObj.shapeSize;
2453
+ }
2424
2454
  get().fabricCanvas.setActiveObject(clonedObj);
2425
2455
  clonedObj.set({
2426
2456
  left: clonedObj.left + 20,
@@ -3507,7 +3537,7 @@ var optionpresets = {
3507
3537
  pathomit: 8,
3508
3538
  rightangleenhance: true,
3509
3539
  // Color quantization
3510
- colorsampling: 10,
3540
+ colorsampling: 1,
3511
3541
  numberofcolors: 8,
3512
3542
  mincolorratio: 0,
3513
3543
  colorquantcycles: 3,
@@ -3526,6 +3556,62 @@ var optionpresets = {
3526
3556
  blurradius: 0,
3527
3557
  blurdelta: 20
3528
3558
  },
3559
+ 'png': {
3560
+ // Tracing
3561
+ corsenabled: true,
3562
+ ltres: 0.08,
3563
+ qtres: 0.1,
3564
+ pathomit: 8,
3565
+ rightangleenhance: true,
3566
+ // Color quantization
3567
+ colorsampling: 10,
3568
+ numberofcolors: 8,
3569
+ mincolorratio: 0,
3570
+ colorquantcycles: 3,
3571
+ // Layering method
3572
+ layering: 0,
3573
+ // SVG rendering
3574
+ strokewidth: 1,
3575
+ linefilter: false,
3576
+ scale: 1,
3577
+ roundcoords: 1,
3578
+ viewbox: false,
3579
+ desc: false,
3580
+ lcpr: 0,
3581
+ qcpr: 0,
3582
+ // Blur
3583
+ blurradius: 0,
3584
+ blurdelta: 20 //20
3585
+ },
3586
+
3587
+ 'jpg': {
3588
+ // Tracing
3589
+ corsenabled: true,
3590
+ ltres: 0.9,
3591
+ qtres: 0.9,
3592
+ pathomit: 16,
3593
+ rightangleenhance: true,
3594
+ // Color quantization
3595
+ colorsampling: 5,
3596
+ numberofcolors: 8,
3597
+ mincolorratio: 0,
3598
+ colorquantcycles: 10,
3599
+ // Layering method
3600
+ layering: 0,
3601
+ // SVG rendering
3602
+ strokewidth: 1,
3603
+ linefilter: false,
3604
+ scale: 1,
3605
+ roundcoords: 1,
3606
+ viewbox: false,
3607
+ desc: false,
3608
+ lcpr: 0,
3609
+ qcpr: 0,
3610
+ // Blur
3611
+ blurradius: 0.5,
3612
+ blurdelta: 10 //20
3613
+ },
3614
+
3529
3615
  'posterized1': {
3530
3616
  colorsampling: 0,
3531
3617
  numberofcolors: 2
@@ -3880,7 +3966,7 @@ var converterSlice = function converterSlice(set, get) {
3880
3966
  }
3881
3967
  return loadImageFromURL;
3882
3968
  }(),
3883
- imageToSVG: function imageToSVG(data, isSVG, convert) {
3969
+ imageToSVG: function imageToSVG(data, ext, isSVG, convert) {
3884
3970
  if (isSVG === void 0) {
3885
3971
  isSVG = false;
3886
3972
  }
@@ -3909,7 +3995,7 @@ var converterSlice = function converterSlice(set, get) {
3909
3995
  imageData: svgstr
3910
3996
  });
3911
3997
  processImage(svgstr, 8);
3912
- }, optionpresets["default"]);
3998
+ }, ext && (ext.toLowerCase() === "jpg" || ext.toLowerCase() === "jpeg") ? optionpresets.jpg : ext.toLowerCase() === "png" ? optionpresets.png : optionpresets["default"]);
3913
3999
  }
3914
4000
  } else {
3915
4001
  processImage(data, 8);
@@ -4692,14 +4778,14 @@ var initCanvas = function initCanvas() {
4692
4778
  return Math.abs(scaledObjCenterX - canvasCenterX) < threshold;
4693
4779
  }
4694
4780
  var horizontalLine = new fabric.Line([0, canv.height / 2, canv.height, canv.height / 2], {
4695
- stroke: 'red',
4781
+ stroke: "red",
4696
4782
  scaleX: 11,
4697
4783
  visible: false,
4698
4784
  selectable: false,
4699
4785
  type: 'line'
4700
4786
  });
4701
4787
  var verticalLine = new fabric.Line([canv.width / 2, 0, canv.width / 2, canv.width], {
4702
- stroke: 'red',
4788
+ stroke: "red",
4703
4789
  visible: false,
4704
4790
  selectable: false,
4705
4791
  type: 'line'
@@ -4820,14 +4906,13 @@ var initCanvas = function initCanvas() {
4820
4906
  }
4821
4907
 
4822
4908
  var removeItem = function removeItem(value) {
4823
- //@ts-ignore
4909
+ //@ts-ignore
4824
4910
  var index = use3dddPlus.getState().storeAllObject.findIndex(function (obj) {
4825
4911
  return obj.id === value.id;
4826
4912
  });
4827
4913
  if (index === -1 && value && value._objects && value._objects.length > 0) {
4828
- var index = use3dddPlus.getState()
4829
4914
  //@ts-ignore
4830
- .storeAllObject.indexOf(value._objects[0]);
4915
+ var index = use3dddPlus.getState().storeAllObject.indexOf(value._objects[0]);
4831
4916
  }
4832
4917
  if (index > -1) {
4833
4918
  use3dddPlus.getState().storeAllObject.splice(index, 1);
@@ -4942,6 +5027,19 @@ var initCanvas = function initCanvas() {
4942
5027
  height1 = obj.height;
4943
5028
  }
4944
5029
  });
5030
+ canv.on('object:rotating', function (e) {
5031
+ var obj = e.target;
5032
+ if (obj.getBoundingRect().top < 0 || obj.getBoundingRect().left < 0) {
5033
+ obj.top = Math.max(obj.top, obj.top - obj.getBoundingRect().top);
5034
+ obj.left = Math.max(obj.left, obj.left - obj.getBoundingRect().left);
5035
+ obj.setCoords();
5036
+ }
5037
+ if (obj.getBoundingRect().top + obj.getBoundingRect().height > obj.canvas.height || obj.getBoundingRect().left + obj.getBoundingRect().width > obj.canvas.width) {
5038
+ obj.top = Math.min(obj.top, obj.canvas.height - obj.getBoundingRect().height + obj.top - obj.getBoundingRect().top);
5039
+ obj.left = Math.min(obj.left, obj.canvas.width - obj.getBoundingRect().width + obj.left - obj.getBoundingRect().left);
5040
+ obj.setCoords();
5041
+ }
5042
+ });
4945
5043
  return canv;
4946
5044
  };
4947
5045
 
@@ -6140,13 +6238,15 @@ var PopUpCanvas = function PopUpCanvas() {
6140
6238
  // Iterate through objects on the canvas and check if any intersect with the mouse click
6141
6239
  var removedColors = [];
6142
6240
  use3dddPlus.getState().popUpCanvasUpdateModification(true);
6241
+ var color;
6143
6242
  popupCanv.forEachObject(function (obj) {
6144
6243
  if (obj.type === 'path') {
6145
6244
  //@ts-ignore
6146
- if (obj.containsPoint(mouseClick)) {
6245
+ if (obj.containsPoint(mouseClick) && !color) {
6147
6246
  removedColors.push(obj.fill);
6148
6247
  popupCanv.remove(obj);
6149
6248
  popupCanv.renderAll();
6249
+ color = obj.fill;
6150
6250
  }
6151
6251
  }
6152
6252
  });
@@ -6602,7 +6702,12 @@ var PopUpCanvas = function PopUpCanvas() {
6602
6702
  textAlign: 'center',
6603
6703
  marginBottom: '3px'
6604
6704
  }
6605
- }, c.updated);
6705
+ }, React.createElement("span", {
6706
+ style: {
6707
+ color: '#ffffff',
6708
+ mixBlendMode: 'difference'
6709
+ }
6710
+ }, c.updated));
6606
6711
  })), React.createElement("div", {
6607
6712
  className: "text-[#E11A38]",
6608
6713
  style: {
@@ -6675,7 +6780,7 @@ var UploadLogo = function UploadLogo() {
6675
6780
  _context.next = 5;
6676
6781
  break;
6677
6782
  }
6678
- imageToSVG(data, true);
6783
+ imageToSVG(data, ext, true);
6679
6784
  _context.next = 29;
6680
6785
  break;
6681
6786
  case 5:
@@ -6687,7 +6792,7 @@ var UploadLogo = function UploadLogo() {
6687
6792
  return pdfConverter(data);
6688
6793
  case 8:
6689
6794
  pdfData = _context.sent;
6690
- imageToSVG(pdfData);
6795
+ imageToSVG(pdfData, ext);
6691
6796
  _context.next = 29;
6692
6797
  break;
6693
6798
  case 12:
@@ -6699,7 +6804,7 @@ var UploadLogo = function UploadLogo() {
6699
6804
  return tiffConvert(data);
6700
6805
  case 15:
6701
6806
  tiffData = _context.sent;
6702
- imageToSVG(tiffData);
6807
+ imageToSVG(tiffData, ext);
6703
6808
  _context.next = 29;
6704
6809
  break;
6705
6810
  case 19:
@@ -6719,13 +6824,13 @@ var UploadLogo = function UploadLogo() {
6719
6824
  fetch(aiToSvg.s3_file_url).then(function (response) {
6720
6825
  return response.text();
6721
6826
  }).then(function (svgText) {
6722
- imageToSVG(svgText, false, false);
6827
+ imageToSVG(svgText, ext, false, false);
6723
6828
  });
6724
6829
  _context.next = 29;
6725
6830
  break;
6726
6831
  case 27:
6727
6832
  objectURL = URL.createObjectURL(data);
6728
- imageToSVG(objectURL);
6833
+ imageToSVG(objectURL, ext);
6729
6834
  case 29:
6730
6835
  setSelectedFile(null);
6731
6836
  case 30:
@@ -8228,8 +8333,8 @@ var Rightmenu = function Rightmenu() {
8228
8333
  });
8229
8334
  _text.left = textSelected.left;
8230
8335
  _text.top = textSelected.top;
8231
- _text.width = textSelected.width;
8232
- _text.height = textSelected.height;
8336
+ _text.width = _text.getBoundingRect().width;
8337
+ _text.height = _text.getBoundingRect().height;
8233
8338
  _text.scaleX = textSelected.scaleX;
8234
8339
  _text.scaleY = textSelected.scaleY;
8235
8340
  // delete the active text object
@@ -8240,14 +8345,17 @@ var Rightmenu = function Rightmenu() {
8240
8345
  // Add the text object keeping same properties
8241
8346
  canvas.add(_text);
8242
8347
  _text.setCoords();
8243
- //@ts-ignore
8244
- use3dddPlus.getState().forIconCapture();
8245
- _text['icon'] = use3dddPlus.getState().iconImage;
8246
- updateStoreAllObject(_text);
8348
+ // set active object as path text
8247
8349
  canvas.setActiveObject(_text);
8248
8350
  use3dddPlus.setState({
8249
8351
  activeSelection: _text
8250
8352
  });
8353
+ //@ts-ignore
8354
+ use3dddPlus.getState().forIconCapture();
8355
+ _text['icon'] = use3dddPlus.getState().iconImage;
8356
+ updateStoreAllObject(_text);
8357
+ // canvas.setActiveObject(text);
8358
+ // use3dddPlus.setState({ activeSelection: text });
8251
8359
  canvas.renderAll();
8252
8360
  // cancel performing further functions & return back from function
8253
8361
  return _context2.abrupt("return");
@@ -8460,14 +8568,33 @@ var Rightmenu = function Rightmenu() {
8460
8568
  canvas.renderAll();
8461
8569
  };
8462
8570
  var handleSliderChange = function handleSliderChange(event) {
8463
- var brNew = textSelected.getBoundingRect();
8571
+ var fontSize = textSelected.fontSize;
8572
+ var toReduceSize = event.target.value - fontSize;
8573
+ var dublicateText = textSelected;
8574
+ // let brNew;
8575
+ dublicateText.set('fontSize', event.target.value);
8576
+ // if (currentSelection === 'path') {
8577
+ // textShapeChange(dublicateText.shapeType, true);
8578
+ // brNew = use3dddPlus.getState().activeSelection.getBoundingRect();
8579
+ // } else {
8580
+ // brNew = dublicateText.getBoundingRect();
8581
+ // }
8582
+ var brNew = dublicateText.getBoundingRect();
8464
8583
  if (brNew.width + brNew.left >= textSelected.canvas.width || brNew.height + brNew.top >= textSelected.canvas.height || brNew.left < 0 || brNew.top < 0) {
8465
- textSelected.set('fontSize', event.target.value - 1);
8466
8584
  if (currentSelection === 'path') {
8585
+ textSelected.set('fontSize', event.target.value - (Math.sign(toReduceSize) >= 0 ? toReduceSize : 1));
8467
8586
  textShapeChange(textSelected.shapeType, true);
8587
+ } else {
8588
+ if (brNew.left < 0) {
8589
+ textSelected.set('left', textSelected.left + 1);
8590
+ }
8591
+ if (brNew.top < 0) {
8592
+ textSelected.set('top', textSelected.top + 1);
8593
+ }
8594
+ textSelected.set('fontSize', event.target.value - (Math.sign(toReduceSize) >= 0 ? toReduceSize : 1));
8468
8595
  }
8469
8596
  } else {
8470
- if (textSelected.fontSize > event.target.value) {
8597
+ if (fontSize > event.target.value) {
8471
8598
  textSelected.set('top', textSelected.top + 1);
8472
8599
  textSelected.set('left', textSelected.left + 1);
8473
8600
  } else {
@@ -8987,7 +9114,7 @@ var Rightmenu = function Rightmenu() {
8987
9114
  id: "shapeSize",
8988
9115
  name: "shapeSize",
8989
9116
  step: "10",
8990
- value: textSelected.shapeSize ? textSelected.shapeSize : shapeSizeVal,
9117
+ value: shapeSizeVal,
8991
9118
  className: "border border-[#EBEBEB] py-[10px] pl-[16px] mb-[16.5px] w-[145px]",
8992
9119
  onChange: textShapeSizeHandler
8993
9120
  })))), currentSelection === 'group' && React.createElement(React.Fragment, null, React.createElement("div", {
@@ -9105,7 +9232,12 @@ var Rightmenu = function Rightmenu() {
9105
9232
  textAlign: 'center',
9106
9233
  marginBottom: '3px'
9107
9234
  }
9108
- }, c);
9235
+ }, React.createElement("span", {
9236
+ style: {
9237
+ color: '#ffffff',
9238
+ mixBlendMode: 'difference'
9239
+ }
9240
+ }, c));
9109
9241
  }))), React.createElement("button", {
9110
9242
  type: "button",
9111
9243
  className: "mt-3 inline-flex justify-center bg-white px-[110px] py-2 text-sm font-medium text-[#E11A38] shadow-sm ring-1 ring-inset ring-[#E11A38] hover:bg-gray-50 sm:mt-0 w-full",