@threedddplus/logoeditor 0.0.66 → 0.0.68

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);
@@ -4601,6 +4687,7 @@ var initCanvas = function initCanvas() {
4601
4687
  getAllColors();
4602
4688
  };
4603
4689
  var onObjectMoving = function onObjectMoving(e) {
4690
+ console.log('onMoveing', e);
4604
4691
  use3dddPlus.getState().updateModifaction(false);
4605
4692
  var obj = e.target;
4606
4693
  // if (
@@ -4692,14 +4779,14 @@ var initCanvas = function initCanvas() {
4692
4779
  return Math.abs(scaledObjCenterX - canvasCenterX) < threshold;
4693
4780
  }
4694
4781
  var horizontalLine = new fabric.Line([0, canv.height / 2, canv.height, canv.height / 2], {
4695
- stroke: 'red',
4782
+ stroke: "red",
4696
4783
  scaleX: 11,
4697
4784
  visible: false,
4698
4785
  selectable: false,
4699
4786
  type: 'line'
4700
4787
  });
4701
4788
  var verticalLine = new fabric.Line([canv.width / 2, 0, canv.width / 2, canv.width], {
4702
- stroke: 'red',
4789
+ stroke: "red",
4703
4790
  visible: false,
4704
4791
  selectable: false,
4705
4792
  type: 'line'
@@ -4820,14 +4907,13 @@ var initCanvas = function initCanvas() {
4820
4907
  }
4821
4908
 
4822
4909
  var removeItem = function removeItem(value) {
4823
- //@ts-ignore
4910
+ //@ts-ignore
4824
4911
  var index = use3dddPlus.getState().storeAllObject.findIndex(function (obj) {
4825
4912
  return obj.id === value.id;
4826
4913
  });
4827
4914
  if (index === -1 && value && value._objects && value._objects.length > 0) {
4828
- var index = use3dddPlus.getState()
4829
4915
  //@ts-ignore
4830
- .storeAllObject.indexOf(value._objects[0]);
4916
+ var index = use3dddPlus.getState().storeAllObject.indexOf(value._objects[0]);
4831
4917
  }
4832
4918
  if (index > -1) {
4833
4919
  use3dddPlus.getState().storeAllObject.splice(index, 1);
@@ -4942,6 +5028,19 @@ var initCanvas = function initCanvas() {
4942
5028
  height1 = obj.height;
4943
5029
  }
4944
5030
  });
5031
+ canv.on('object:rotating', function (e) {
5032
+ var obj = e.target;
5033
+ if (obj.getBoundingRect().top < 0 || obj.getBoundingRect().left < 0) {
5034
+ obj.top = Math.max(obj.top, obj.top - obj.getBoundingRect().top);
5035
+ obj.left = Math.max(obj.left, obj.left - obj.getBoundingRect().left);
5036
+ obj.setCoords();
5037
+ }
5038
+ if (obj.getBoundingRect().top + obj.getBoundingRect().height > obj.canvas.height || obj.getBoundingRect().left + obj.getBoundingRect().width > obj.canvas.width) {
5039
+ obj.top = Math.min(obj.top, obj.canvas.height - obj.getBoundingRect().height + obj.top - obj.getBoundingRect().top);
5040
+ obj.left = Math.min(obj.left, obj.canvas.width - obj.getBoundingRect().width + obj.left - obj.getBoundingRect().left);
5041
+ obj.setCoords();
5042
+ }
5043
+ });
4945
5044
  return canv;
4946
5045
  };
4947
5046
 
@@ -6140,13 +6239,15 @@ var PopUpCanvas = function PopUpCanvas() {
6140
6239
  // Iterate through objects on the canvas and check if any intersect with the mouse click
6141
6240
  var removedColors = [];
6142
6241
  use3dddPlus.getState().popUpCanvasUpdateModification(true);
6242
+ var color;
6143
6243
  popupCanv.forEachObject(function (obj) {
6144
6244
  if (obj.type === 'path') {
6145
6245
  //@ts-ignore
6146
- if (obj.containsPoint(mouseClick)) {
6246
+ if (obj.containsPoint(mouseClick) && !color) {
6147
6247
  removedColors.push(obj.fill);
6148
6248
  popupCanv.remove(obj);
6149
6249
  popupCanv.renderAll();
6250
+ color = obj.fill;
6150
6251
  }
6151
6252
  }
6152
6253
  });
@@ -6602,7 +6703,12 @@ var PopUpCanvas = function PopUpCanvas() {
6602
6703
  textAlign: 'center',
6603
6704
  marginBottom: '3px'
6604
6705
  }
6605
- }, c.updated);
6706
+ }, React.createElement("span", {
6707
+ style: {
6708
+ color: '#ffffff',
6709
+ mixBlendMode: 'difference'
6710
+ }
6711
+ }, c.updated));
6606
6712
  })), React.createElement("div", {
6607
6713
  className: "text-[#E11A38]",
6608
6714
  style: {
@@ -6675,7 +6781,7 @@ var UploadLogo = function UploadLogo() {
6675
6781
  _context.next = 5;
6676
6782
  break;
6677
6783
  }
6678
- imageToSVG(data, true);
6784
+ imageToSVG(data, ext, true);
6679
6785
  _context.next = 29;
6680
6786
  break;
6681
6787
  case 5:
@@ -6687,7 +6793,7 @@ var UploadLogo = function UploadLogo() {
6687
6793
  return pdfConverter(data);
6688
6794
  case 8:
6689
6795
  pdfData = _context.sent;
6690
- imageToSVG(pdfData);
6796
+ imageToSVG(pdfData, ext);
6691
6797
  _context.next = 29;
6692
6798
  break;
6693
6799
  case 12:
@@ -6699,7 +6805,7 @@ var UploadLogo = function UploadLogo() {
6699
6805
  return tiffConvert(data);
6700
6806
  case 15:
6701
6807
  tiffData = _context.sent;
6702
- imageToSVG(tiffData);
6808
+ imageToSVG(tiffData, ext);
6703
6809
  _context.next = 29;
6704
6810
  break;
6705
6811
  case 19:
@@ -6719,13 +6825,13 @@ var UploadLogo = function UploadLogo() {
6719
6825
  fetch(aiToSvg.s3_file_url).then(function (response) {
6720
6826
  return response.text();
6721
6827
  }).then(function (svgText) {
6722
- imageToSVG(svgText, false, false);
6828
+ imageToSVG(svgText, ext, false, false);
6723
6829
  });
6724
6830
  _context.next = 29;
6725
6831
  break;
6726
6832
  case 27:
6727
6833
  objectURL = URL.createObjectURL(data);
6728
- imageToSVG(objectURL);
6834
+ imageToSVG(objectURL, ext);
6729
6835
  case 29:
6730
6836
  setSelectedFile(null);
6731
6837
  case 30:
@@ -8228,8 +8334,8 @@ var Rightmenu = function Rightmenu() {
8228
8334
  });
8229
8335
  _text.left = textSelected.left;
8230
8336
  _text.top = textSelected.top;
8231
- _text.width = textSelected.width;
8232
- _text.height = textSelected.height;
8337
+ _text.width = _text.getBoundingRect().width;
8338
+ _text.height = _text.getBoundingRect().height;
8233
8339
  _text.scaleX = textSelected.scaleX;
8234
8340
  _text.scaleY = textSelected.scaleY;
8235
8341
  // delete the active text object
@@ -8240,14 +8346,17 @@ var Rightmenu = function Rightmenu() {
8240
8346
  // Add the text object keeping same properties
8241
8347
  canvas.add(_text);
8242
8348
  _text.setCoords();
8243
- //@ts-ignore
8244
- use3dddPlus.getState().forIconCapture();
8245
- _text['icon'] = use3dddPlus.getState().iconImage;
8246
- updateStoreAllObject(_text);
8349
+ // set active object as path text
8247
8350
  canvas.setActiveObject(_text);
8248
8351
  use3dddPlus.setState({
8249
8352
  activeSelection: _text
8250
8353
  });
8354
+ //@ts-ignore
8355
+ use3dddPlus.getState().forIconCapture();
8356
+ _text['icon'] = use3dddPlus.getState().iconImage;
8357
+ updateStoreAllObject(_text);
8358
+ // canvas.setActiveObject(text);
8359
+ // use3dddPlus.setState({ activeSelection: text });
8251
8360
  canvas.renderAll();
8252
8361
  // cancel performing further functions & return back from function
8253
8362
  return _context2.abrupt("return");
@@ -8460,14 +8569,33 @@ var Rightmenu = function Rightmenu() {
8460
8569
  canvas.renderAll();
8461
8570
  };
8462
8571
  var handleSliderChange = function handleSliderChange(event) {
8463
- var brNew = textSelected.getBoundingRect();
8572
+ var fontSize = textSelected.fontSize;
8573
+ var toReduceSize = event.target.value - fontSize;
8574
+ var dublicateText = textSelected;
8575
+ // let brNew;
8576
+ dublicateText.set('fontSize', event.target.value);
8577
+ // if (currentSelection === 'path') {
8578
+ // textShapeChange(dublicateText.shapeType, true);
8579
+ // brNew = use3dddPlus.getState().activeSelection.getBoundingRect();
8580
+ // } else {
8581
+ // brNew = dublicateText.getBoundingRect();
8582
+ // }
8583
+ var brNew = dublicateText.getBoundingRect();
8464
8584
  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
8585
  if (currentSelection === 'path') {
8586
+ textSelected.set('fontSize', event.target.value - (Math.sign(toReduceSize) >= 0 ? toReduceSize : 1));
8467
8587
  textShapeChange(textSelected.shapeType, true);
8588
+ } else {
8589
+ if (brNew.left < 0) {
8590
+ textSelected.set('left', textSelected.left + 1);
8591
+ }
8592
+ if (brNew.top < 0) {
8593
+ textSelected.set('top', textSelected.top + 1);
8594
+ }
8595
+ textSelected.set('fontSize', event.target.value - (Math.sign(toReduceSize) >= 0 ? toReduceSize : 1));
8468
8596
  }
8469
8597
  } else {
8470
- if (textSelected.fontSize > event.target.value) {
8598
+ if (fontSize > event.target.value) {
8471
8599
  textSelected.set('top', textSelected.top + 1);
8472
8600
  textSelected.set('left', textSelected.left + 1);
8473
8601
  } else {
@@ -8987,7 +9115,7 @@ var Rightmenu = function Rightmenu() {
8987
9115
  id: "shapeSize",
8988
9116
  name: "shapeSize",
8989
9117
  step: "10",
8990
- value: textSelected.shapeSize ? textSelected.shapeSize : shapeSizeVal,
9118
+ value: shapeSizeVal,
8991
9119
  className: "border border-[#EBEBEB] py-[10px] pl-[16px] mb-[16.5px] w-[145px]",
8992
9120
  onChange: textShapeSizeHandler
8993
9121
  })))), currentSelection === 'group' && React.createElement(React.Fragment, null, React.createElement("div", {
@@ -9105,7 +9233,12 @@ var Rightmenu = function Rightmenu() {
9105
9233
  textAlign: 'center',
9106
9234
  marginBottom: '3px'
9107
9235
  }
9108
- }, c);
9236
+ }, React.createElement("span", {
9237
+ style: {
9238
+ color: '#ffffff',
9239
+ mixBlendMode: 'difference'
9240
+ }
9241
+ }, c));
9109
9242
  }))), React.createElement("button", {
9110
9243
  type: "button",
9111
9244
  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",