@threedddplus/logoeditor 0.0.62 → 0.0.63

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.
@@ -2455,6 +2455,37 @@ var fabricSlice = function fabricSlice(set, get) {
2455
2455
  // if(get().count + 1 !== get().storeHistory.length){
2456
2456
  get().fabricCanvas.clear().renderAll();
2457
2457
  get().fabricCanvas.loadFromJSON(get().storeHistory[get().storeHistory.length - 1 - (get().count > 1 ? get().count - 1 : 0)]);
2458
+ // Remove lines
2459
+ get().fabricCanvas.getObjects().forEach(function (obj) {
2460
+ if (obj.type === 'line') {
2461
+ get().fabricCanvas.remove(obj);
2462
+ }
2463
+ });
2464
+ // Add lines
2465
+ var horizontalLine = new fabric.Line([0, get().fabricCanvas.height / 2, get().fabricCanvas.height, get().fabricCanvas.height / 2], {
2466
+ stroke: "red",
2467
+ scaleX: 11,
2468
+ visible: false,
2469
+ selectable: false,
2470
+ type: 'line'
2471
+ });
2472
+ var verticalLine = new fabric.Line([get().fabricCanvas.width / 2, 0, get().fabricCanvas.width / 2, get().fabricCanvas.width], {
2473
+ stroke: "red",
2474
+ visible: false,
2475
+ selectable: false,
2476
+ type: 'line'
2477
+ });
2478
+ horizontalLine.centerH();
2479
+ get().fabricCanvas.add(horizontalLine);
2480
+ get().fabricCanvas.add(verticalLine);
2481
+ get().fabricCanvas.sendToBack(horizontalLine);
2482
+ get().fabricCanvas.sendToBack(verticalLine);
2483
+ use3dddPlus.setState({
2484
+ horizontalLine: horizontalLine
2485
+ });
2486
+ use3dddPlus.setState({
2487
+ verticalLine: verticalLine
2488
+ });
2458
2489
  get().fabricCanvas.renderAll();
2459
2490
  get().count += 1;
2460
2491
  // }
@@ -2480,6 +2511,37 @@ var fabricSlice = function fabricSlice(set, get) {
2480
2511
  get().fabricCanvas.clear().renderAll();
2481
2512
  var item = Math.abs(get().count - get().storeHistory.length - 2);
2482
2513
  get().fabricCanvas.loadFromJSON(get().storeHistory[item]);
2514
+ // Remove lines
2515
+ get().fabricCanvas.getObjects().forEach(function (obj) {
2516
+ if (obj.type === 'line') {
2517
+ get().fabricCanvas.remove(obj);
2518
+ }
2519
+ });
2520
+ // Add lines
2521
+ var horizontalLine = new fabric.Line([0, get().fabricCanvas.height / 2, get().fabricCanvas.height, get().fabricCanvas.height / 2], {
2522
+ stroke: "red",
2523
+ scaleX: 11,
2524
+ visible: false,
2525
+ selectable: false,
2526
+ type: 'line'
2527
+ });
2528
+ var verticalLine = new fabric.Line([get().fabricCanvas.width / 2, 0, get().fabricCanvas.width / 2, get().fabricCanvas.width], {
2529
+ stroke: "red",
2530
+ visible: false,
2531
+ selectable: false,
2532
+ type: 'line'
2533
+ });
2534
+ horizontalLine.centerH();
2535
+ get().fabricCanvas.add(horizontalLine);
2536
+ get().fabricCanvas.add(verticalLine);
2537
+ get().fabricCanvas.sendBackwards(horizontalLine);
2538
+ get().fabricCanvas.sendBackwards(verticalLine);
2539
+ use3dddPlus.setState({
2540
+ horizontalLine: horizontalLine
2541
+ });
2542
+ use3dddPlus.setState({
2543
+ verticalLine: verticalLine
2544
+ });
2483
2545
  get().fabricCanvas.renderAll();
2484
2546
  get().count -= 1;
2485
2547
  // Update layers
@@ -2652,6 +2714,8 @@ var fabricSlice = function fabricSlice(set, get) {
2652
2714
  horizontalLine.centerH();
2653
2715
  canvas.add(horizontalLine);
2654
2716
  canvas.add(verticalLine);
2717
+ get().fabricCanvas.sendBackwards(horizontalLine);
2718
+ get().fabricCanvas.sendBackwards(verticalLine);
2655
2719
  use3dddPlus.setState({
2656
2720
  horizontalLine: horizontalLine
2657
2721
  });
@@ -2659,6 +2723,7 @@ var fabricSlice = function fabricSlice(set, get) {
2659
2723
  verticalLine: verticalLine
2660
2724
  });
2661
2725
  canvas.renderAll.bind(canvas);
2726
+ canvas.discardActiveObject();
2662
2727
  use3dddPlus.setState({
2663
2728
  selectedStepper: undefined
2664
2729
  });
@@ -3442,7 +3507,7 @@ var optionpresets = {
3442
3507
  pathomit: 8,
3443
3508
  rightangleenhance: true,
3444
3509
  // Color quantization
3445
- colorsampling: 1,
3510
+ colorsampling: 10,
3446
3511
  numberofcolors: 8,
3447
3512
  mincolorratio: 0,
3448
3513
  colorquantcycles: 3,
@@ -4177,7 +4242,9 @@ var ActionButtons = function ActionButtons() {
4177
4242
  activeSelection = _use3dddPlus[1];
4178
4243
  var selectAllHandler = function selectAllHandler() {
4179
4244
  canvas.discardActiveObject();
4180
- var sel = new fabric.ActiveSelection(canvas.getObjects(), {
4245
+ var sel = new fabric.ActiveSelection(canvas.getObjects().filter(function (obj) {
4246
+ return obj.type !== 'line';
4247
+ }), {
4181
4248
  canvas: canvas
4182
4249
  });
4183
4250
  canvas.setActiveObject(sel);
@@ -4211,6 +4278,7 @@ var ActionButtons = function ActionButtons() {
4211
4278
  use3dddPlus.setState({
4212
4279
  selectedAll: false
4213
4280
  });
4281
+ canvas.discardActiveObject();
4214
4282
  // removeItem(activeSelection);
4215
4283
  }
4216
4284
  };
@@ -4545,10 +4613,12 @@ var initCanvas = function initCanvas() {
4545
4613
  if (obj.getBoundingRect().top < 0 || obj.getBoundingRect().left < 0) {
4546
4614
  obj.top = Math.max(obj.top, obj.top - obj.getBoundingRect().top);
4547
4615
  obj.left = Math.max(obj.left, obj.left - obj.getBoundingRect().left);
4616
+ obj.setCoords();
4548
4617
  }
4549
4618
  if (obj.getBoundingRect().top + obj.getBoundingRect().height > obj.canvas.height || obj.getBoundingRect().left + obj.getBoundingRect().width > obj.canvas.width) {
4550
4619
  obj.top = Math.min(obj.top, obj.canvas.height - obj.getBoundingRect().height + obj.top - obj.getBoundingRect().top);
4551
4620
  obj.left = Math.min(obj.left, obj.canvas.width - obj.getBoundingRect().width + obj.left - obj.getBoundingRect().left);
4621
+ obj.setCoords();
4552
4622
  }
4553
4623
  var brNew = obj.getBoundingRect();
4554
4624
  if (brNew.width + brNew.left >= obj.canvas.width || brNew.height + brNew.top >= obj.canvas.height || brNew.left < 0 || brNew.top < 0) ; else {
@@ -4722,11 +4792,31 @@ var initCanvas = function initCanvas() {
4722
4792
  // use3dddPlus.setState({ selectedAll: false });
4723
4793
  // canvas.discardActiveObject().renderAll();
4724
4794
  // } else {
4725
- canvas.remove(canvasTarget);
4726
- canvas.requestRenderAll();
4727
- removeItem(canvasTarget);
4795
+ // canvas.remove(canvasTarget);
4796
+ // canvas.requestRenderAll();
4797
+ // removeItem(canvasTarget);
4728
4798
  // }
4729
4799
  // use3dddPlus.setState({ defaultColorFill: [] });
4800
+ var activeSelection = use3dddPlus.getState().activeSelection;
4801
+ if (activeSelection) {
4802
+ if (activeSelection.icon) {
4803
+ canvas.remove(activeSelection);
4804
+ removeItem(activeSelection);
4805
+ } else if (activeSelection._objects) {
4806
+ activeSelection._objects.map(function (obj) {
4807
+ canvas.remove(obj);
4808
+ removeItem(obj);
4809
+ });
4810
+ }
4811
+ // canvas.remove(activeSelection);
4812
+ use3dddPlus.getState().updateModifaction(true);
4813
+ canvas.requestRenderAll();
4814
+ use3dddPlus.setState({
4815
+ selectedAll: false
4816
+ });
4817
+ canvas.discardActiveObject();
4818
+ // removeItem(activeSelection);
4819
+ }
4730
4820
  }
4731
4821
 
4732
4822
  var removeItem = function removeItem(value) {
@@ -4901,6 +4991,8 @@ var ContextMenu = function ContextMenu() {
4901
4991
  use3dddPlus.setState({
4902
4992
  showContextMenu: false
4903
4993
  });
4994
+ canvas.sendBackwards(use3dddPlus.getState().verticalLine);
4995
+ canvas.sendBackwards(use3dddPlus.getState().horizontalLine);
4904
4996
  };
4905
4997
  var bringForward = function bringForward() {
4906
4998
  canvas.bringForward(activeObj);
@@ -4941,6 +5033,8 @@ var ContextMenu = function ContextMenu() {
4941
5033
  use3dddPlus.setState({
4942
5034
  showContextMenu: false
4943
5035
  });
5036
+ canvas.sendToBack(use3dddPlus.getState().verticalLine);
5037
+ canvas.sendToBack(use3dddPlus.getState().horizontalLine);
4944
5038
  };
4945
5039
  var bringToFront = function bringToFront() {
4946
5040
  canvas.bringToFront(activeObj);
@@ -6044,12 +6138,12 @@ var PopUpCanvas = function PopUpCanvas() {
6044
6138
  // console.log('MOUSE-CLICK-->',mouseClick);
6045
6139
  // Iterate through objects on the canvas and check if any intersect with the mouse click
6046
6140
  var removedColors = [];
6141
+ use3dddPlus.getState().popUpCanvasUpdateModification(true);
6047
6142
  popupCanv.forEachObject(function (obj) {
6048
6143
  if (obj.type === 'path') {
6049
6144
  //@ts-ignore
6050
6145
  if (obj.containsPoint(mouseClick)) {
6051
6146
  removedColors.push(obj.fill);
6052
- use3dddPlus.getState().popUpCanvasUpdateModification(true);
6053
6147
  popupCanv.remove(obj);
6054
6148
  popupCanv.renderAll();
6055
6149
  }
@@ -6102,6 +6196,9 @@ var PopUpCanvas = function PopUpCanvas() {
6102
6196
  use3dddPlus.setState({
6103
6197
  popupCanvasStoreHistory: []
6104
6198
  });
6199
+ use3dddPlus.setState({
6200
+ popUpCanvasCount: 1
6201
+ });
6105
6202
  };
6106
6203
  var popupCanvasContinue = function popupCanvasContinue() {
6107
6204
  if (!conflictColors || conflictColors.length < 1) {
@@ -8896,11 +8993,10 @@ var Rightmenu = function Rightmenu() {
8896
8993
  className: "uppercase font-bold pt-[17px]"
8897
8994
  }, "Colors"), React.createElement("div", {
8898
8995
  className: "flex flex-wrap gap-x-[1rem] mt-[12px]"
8899
- }, activeSelection.colorFill && ((_Object$keys = Object.keys(activeSelection == null ? void 0 : activeSelection.colorFill)) == null ? void 0 : _Object$keys.map(function (item) {
8900
- var _activeSelection$ownM;
8996
+ }, activeSelection.colorFill && ((_Object$keys = Object.keys(activeSelection == null ? void 0 : activeSelection.colorFill)) == null ? void 0 : _Object$keys.map(function (item, i) {
8901
8997
  return React.createElement(ColorImpl, {
8902
8998
  mClass: 'mb-[10px]',
8903
- key: activeSelection.colorFill[item] + (activeSelection == null ? void 0 : (_activeSelection$ownM = activeSelection.ownMatrixCache) == null ? void 0 : _activeSelection$ownM.key),
8999
+ key: 'color-' + i,
8904
9000
  handleChange: changeSVGColor,
8905
9001
  property: item,
8906
9002
  color: activeSelection.colorFill[item]
@@ -8938,10 +9034,10 @@ var Rightmenu = function Rightmenu() {
8938
9034
  className: "uppercase font-bold pt-[17px]"
8939
9035
  }, "Color in Canvas"), React.createElement("div", {
8940
9036
  className: "flex flex-wrap gap-x-[1rem] mt-[12px] mb-[12px]"
8941
- }, allColor == null ? void 0 : allColor.map(function (item) {
9037
+ }, allColor == null ? void 0 : allColor.map(function (item, i) {
8942
9038
  return React.createElement(ColorImpl, {
8943
9039
  mClass: 'mb-[10px]',
8944
- key: item,
9040
+ key: 'color-' + i,
8945
9041
  handleChange: changeSVGTextColor,
8946
9042
  property: item,
8947
9043
  color: item
@@ -8952,10 +9048,10 @@ var Rightmenu = function Rightmenu() {
8952
9048
  className: "uppercase font-bold pt-[17px]"
8953
9049
  }, "Color in Canvas"), React.createElement("div", {
8954
9050
  className: "flex flex-wrap gap-x-[1rem] mt-[12px]"
8955
- }, allColor == null ? void 0 : allColor.map(function (item) {
9051
+ }, allColor == null ? void 0 : allColor.map(function (item, i) {
8956
9052
  return React.createElement(ColorImpl, {
8957
9053
  mClass: 'mb-[10px]',
8958
- key: item,
9054
+ key: 'color-' + i,
8959
9055
  handleChange: changeSVGTextColor,
8960
9056
  property: item,
8961
9057
  color: item
@@ -9436,7 +9532,7 @@ var SaveDesign = function SaveDesign(_ref) {
9436
9532
  while (1) switch (_context.prev = _context.next) {
9437
9533
  case 0:
9438
9534
  if (isSaving) {
9439
- _context.next = 28;
9535
+ _context.next = 30;
9440
9536
  break;
9441
9537
  }
9442
9538
  if (checkValidations()) {
@@ -9522,6 +9618,8 @@ var SaveDesign = function SaveDesign(_ref) {
9522
9618
  horizontalLine.centerH();
9523
9619
  canvas.add(horizontalLine);
9524
9620
  canvas.add(verticalLine);
9621
+ canvas.sendBackwards(horizontalLine);
9622
+ canvas.sendBackwards(verticalLine);
9525
9623
  use3dddPlus.setState({
9526
9624
  horizontalLine: horizontalLine
9527
9625
  });
@@ -9537,7 +9635,7 @@ var SaveDesign = function SaveDesign(_ref) {
9537
9635
  setIsSaving(false);
9538
9636
  console.log('ERROR in Save Logo:', ex);
9539
9637
  });
9540
- case 28:
9638
+ case 30:
9541
9639
  case "end":
9542
9640
  return _context.stop();
9543
9641
  }