@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.
@@ -2463,6 +2463,37 @@ var fabricSlice = function fabricSlice(set, get) {
2463
2463
  // if(get().count + 1 !== get().storeHistory.length){
2464
2464
  get().fabricCanvas.clear().renderAll();
2465
2465
  get().fabricCanvas.loadFromJSON(get().storeHistory[get().storeHistory.length - 1 - (get().count > 1 ? get().count - 1 : 0)]);
2466
+ // Remove lines
2467
+ get().fabricCanvas.getObjects().forEach(function (obj) {
2468
+ if (obj.type === 'line') {
2469
+ get().fabricCanvas.remove(obj);
2470
+ }
2471
+ });
2472
+ // Add lines
2473
+ var horizontalLine = new fabric.fabric.Line([0, get().fabricCanvas.height / 2, get().fabricCanvas.height, get().fabricCanvas.height / 2], {
2474
+ stroke: "red",
2475
+ scaleX: 11,
2476
+ visible: false,
2477
+ selectable: false,
2478
+ type: 'line'
2479
+ });
2480
+ var verticalLine = new fabric.fabric.Line([get().fabricCanvas.width / 2, 0, get().fabricCanvas.width / 2, get().fabricCanvas.width], {
2481
+ stroke: "red",
2482
+ visible: false,
2483
+ selectable: false,
2484
+ type: 'line'
2485
+ });
2486
+ horizontalLine.centerH();
2487
+ get().fabricCanvas.add(horizontalLine);
2488
+ get().fabricCanvas.add(verticalLine);
2489
+ get().fabricCanvas.sendToBack(horizontalLine);
2490
+ get().fabricCanvas.sendToBack(verticalLine);
2491
+ use3dddPlus.setState({
2492
+ horizontalLine: horizontalLine
2493
+ });
2494
+ use3dddPlus.setState({
2495
+ verticalLine: verticalLine
2496
+ });
2466
2497
  get().fabricCanvas.renderAll();
2467
2498
  get().count += 1;
2468
2499
  // }
@@ -2488,6 +2519,37 @@ var fabricSlice = function fabricSlice(set, get) {
2488
2519
  get().fabricCanvas.clear().renderAll();
2489
2520
  var item = Math.abs(get().count - get().storeHistory.length - 2);
2490
2521
  get().fabricCanvas.loadFromJSON(get().storeHistory[item]);
2522
+ // Remove lines
2523
+ get().fabricCanvas.getObjects().forEach(function (obj) {
2524
+ if (obj.type === 'line') {
2525
+ get().fabricCanvas.remove(obj);
2526
+ }
2527
+ });
2528
+ // Add lines
2529
+ var horizontalLine = new fabric.fabric.Line([0, get().fabricCanvas.height / 2, get().fabricCanvas.height, get().fabricCanvas.height / 2], {
2530
+ stroke: "red",
2531
+ scaleX: 11,
2532
+ visible: false,
2533
+ selectable: false,
2534
+ type: 'line'
2535
+ });
2536
+ var verticalLine = new fabric.fabric.Line([get().fabricCanvas.width / 2, 0, get().fabricCanvas.width / 2, get().fabricCanvas.width], {
2537
+ stroke: "red",
2538
+ visible: false,
2539
+ selectable: false,
2540
+ type: 'line'
2541
+ });
2542
+ horizontalLine.centerH();
2543
+ get().fabricCanvas.add(horizontalLine);
2544
+ get().fabricCanvas.add(verticalLine);
2545
+ get().fabricCanvas.sendBackwards(horizontalLine);
2546
+ get().fabricCanvas.sendBackwards(verticalLine);
2547
+ use3dddPlus.setState({
2548
+ horizontalLine: horizontalLine
2549
+ });
2550
+ use3dddPlus.setState({
2551
+ verticalLine: verticalLine
2552
+ });
2491
2553
  get().fabricCanvas.renderAll();
2492
2554
  get().count -= 1;
2493
2555
  // Update layers
@@ -2660,6 +2722,8 @@ var fabricSlice = function fabricSlice(set, get) {
2660
2722
  horizontalLine.centerH();
2661
2723
  canvas.add(horizontalLine);
2662
2724
  canvas.add(verticalLine);
2725
+ get().fabricCanvas.sendBackwards(horizontalLine);
2726
+ get().fabricCanvas.sendBackwards(verticalLine);
2663
2727
  use3dddPlus.setState({
2664
2728
  horizontalLine: horizontalLine
2665
2729
  });
@@ -2667,6 +2731,7 @@ var fabricSlice = function fabricSlice(set, get) {
2667
2731
  verticalLine: verticalLine
2668
2732
  });
2669
2733
  canvas.renderAll.bind(canvas);
2734
+ canvas.discardActiveObject();
2670
2735
  use3dddPlus.setState({
2671
2736
  selectedStepper: undefined
2672
2737
  });
@@ -3450,7 +3515,7 @@ var optionpresets = {
3450
3515
  pathomit: 8,
3451
3516
  rightangleenhance: true,
3452
3517
  // Color quantization
3453
- colorsampling: 1,
3518
+ colorsampling: 10,
3454
3519
  numberofcolors: 8,
3455
3520
  mincolorratio: 0,
3456
3521
  colorquantcycles: 3,
@@ -4185,7 +4250,9 @@ var ActionButtons = function ActionButtons() {
4185
4250
  activeSelection = _use3dddPlus[1];
4186
4251
  var selectAllHandler = function selectAllHandler() {
4187
4252
  canvas.discardActiveObject();
4188
- var sel = new fabric.fabric.ActiveSelection(canvas.getObjects(), {
4253
+ var sel = new fabric.fabric.ActiveSelection(canvas.getObjects().filter(function (obj) {
4254
+ return obj.type !== 'line';
4255
+ }), {
4189
4256
  canvas: canvas
4190
4257
  });
4191
4258
  canvas.setActiveObject(sel);
@@ -4219,6 +4286,7 @@ var ActionButtons = function ActionButtons() {
4219
4286
  use3dddPlus.setState({
4220
4287
  selectedAll: false
4221
4288
  });
4289
+ canvas.discardActiveObject();
4222
4290
  // removeItem(activeSelection);
4223
4291
  }
4224
4292
  };
@@ -4553,10 +4621,12 @@ var initCanvas = function initCanvas() {
4553
4621
  if (obj.getBoundingRect().top < 0 || obj.getBoundingRect().left < 0) {
4554
4622
  obj.top = Math.max(obj.top, obj.top - obj.getBoundingRect().top);
4555
4623
  obj.left = Math.max(obj.left, obj.left - obj.getBoundingRect().left);
4624
+ obj.setCoords();
4556
4625
  }
4557
4626
  if (obj.getBoundingRect().top + obj.getBoundingRect().height > obj.canvas.height || obj.getBoundingRect().left + obj.getBoundingRect().width > obj.canvas.width) {
4558
4627
  obj.top = Math.min(obj.top, obj.canvas.height - obj.getBoundingRect().height + obj.top - obj.getBoundingRect().top);
4559
4628
  obj.left = Math.min(obj.left, obj.canvas.width - obj.getBoundingRect().width + obj.left - obj.getBoundingRect().left);
4629
+ obj.setCoords();
4560
4630
  }
4561
4631
  var brNew = obj.getBoundingRect();
4562
4632
  if (brNew.width + brNew.left >= obj.canvas.width || brNew.height + brNew.top >= obj.canvas.height || brNew.left < 0 || brNew.top < 0) ; else {
@@ -4730,11 +4800,31 @@ var initCanvas = function initCanvas() {
4730
4800
  // use3dddPlus.setState({ selectedAll: false });
4731
4801
  // canvas.discardActiveObject().renderAll();
4732
4802
  // } else {
4733
- canvas.remove(canvasTarget);
4734
- canvas.requestRenderAll();
4735
- removeItem(canvasTarget);
4803
+ // canvas.remove(canvasTarget);
4804
+ // canvas.requestRenderAll();
4805
+ // removeItem(canvasTarget);
4736
4806
  // }
4737
4807
  // use3dddPlus.setState({ defaultColorFill: [] });
4808
+ var activeSelection = use3dddPlus.getState().activeSelection;
4809
+ if (activeSelection) {
4810
+ if (activeSelection.icon) {
4811
+ canvas.remove(activeSelection);
4812
+ removeItem(activeSelection);
4813
+ } else if (activeSelection._objects) {
4814
+ activeSelection._objects.map(function (obj) {
4815
+ canvas.remove(obj);
4816
+ removeItem(obj);
4817
+ });
4818
+ }
4819
+ // canvas.remove(activeSelection);
4820
+ use3dddPlus.getState().updateModifaction(true);
4821
+ canvas.requestRenderAll();
4822
+ use3dddPlus.setState({
4823
+ selectedAll: false
4824
+ });
4825
+ canvas.discardActiveObject();
4826
+ // removeItem(activeSelection);
4827
+ }
4738
4828
  }
4739
4829
 
4740
4830
  var removeItem = function removeItem(value) {
@@ -4909,6 +4999,8 @@ var ContextMenu = function ContextMenu() {
4909
4999
  use3dddPlus.setState({
4910
5000
  showContextMenu: false
4911
5001
  });
5002
+ canvas.sendBackwards(use3dddPlus.getState().verticalLine);
5003
+ canvas.sendBackwards(use3dddPlus.getState().horizontalLine);
4912
5004
  };
4913
5005
  var bringForward = function bringForward() {
4914
5006
  canvas.bringForward(activeObj);
@@ -4949,6 +5041,8 @@ var ContextMenu = function ContextMenu() {
4949
5041
  use3dddPlus.setState({
4950
5042
  showContextMenu: false
4951
5043
  });
5044
+ canvas.sendToBack(use3dddPlus.getState().verticalLine);
5045
+ canvas.sendToBack(use3dddPlus.getState().horizontalLine);
4952
5046
  };
4953
5047
  var bringToFront = function bringToFront() {
4954
5048
  canvas.bringToFront(activeObj);
@@ -6052,12 +6146,12 @@ var PopUpCanvas = function PopUpCanvas() {
6052
6146
  // console.log('MOUSE-CLICK-->',mouseClick);
6053
6147
  // Iterate through objects on the canvas and check if any intersect with the mouse click
6054
6148
  var removedColors = [];
6149
+ use3dddPlus.getState().popUpCanvasUpdateModification(true);
6055
6150
  popupCanv.forEachObject(function (obj) {
6056
6151
  if (obj.type === 'path') {
6057
6152
  //@ts-ignore
6058
6153
  if (obj.containsPoint(mouseClick)) {
6059
6154
  removedColors.push(obj.fill);
6060
- use3dddPlus.getState().popUpCanvasUpdateModification(true);
6061
6155
  popupCanv.remove(obj);
6062
6156
  popupCanv.renderAll();
6063
6157
  }
@@ -6110,6 +6204,9 @@ var PopUpCanvas = function PopUpCanvas() {
6110
6204
  use3dddPlus.setState({
6111
6205
  popupCanvasStoreHistory: []
6112
6206
  });
6207
+ use3dddPlus.setState({
6208
+ popUpCanvasCount: 1
6209
+ });
6113
6210
  };
6114
6211
  var popupCanvasContinue = function popupCanvasContinue() {
6115
6212
  if (!conflictColors || conflictColors.length < 1) {
@@ -8904,11 +9001,10 @@ var Rightmenu = function Rightmenu() {
8904
9001
  className: "uppercase font-bold pt-[17px]"
8905
9002
  }, "Colors"), React__default.createElement("div", {
8906
9003
  className: "flex flex-wrap gap-x-[1rem] mt-[12px]"
8907
- }, activeSelection.colorFill && ((_Object$keys = Object.keys(activeSelection == null ? void 0 : activeSelection.colorFill)) == null ? void 0 : _Object$keys.map(function (item) {
8908
- var _activeSelection$ownM;
9004
+ }, activeSelection.colorFill && ((_Object$keys = Object.keys(activeSelection == null ? void 0 : activeSelection.colorFill)) == null ? void 0 : _Object$keys.map(function (item, i) {
8909
9005
  return React__default.createElement(ColorImpl, {
8910
9006
  mClass: 'mb-[10px]',
8911
- key: activeSelection.colorFill[item] + (activeSelection == null ? void 0 : (_activeSelection$ownM = activeSelection.ownMatrixCache) == null ? void 0 : _activeSelection$ownM.key),
9007
+ key: 'color-' + i,
8912
9008
  handleChange: changeSVGColor,
8913
9009
  property: item,
8914
9010
  color: activeSelection.colorFill[item]
@@ -8946,10 +9042,10 @@ var Rightmenu = function Rightmenu() {
8946
9042
  className: "uppercase font-bold pt-[17px]"
8947
9043
  }, "Color in Canvas"), React__default.createElement("div", {
8948
9044
  className: "flex flex-wrap gap-x-[1rem] mt-[12px] mb-[12px]"
8949
- }, allColor == null ? void 0 : allColor.map(function (item) {
9045
+ }, allColor == null ? void 0 : allColor.map(function (item, i) {
8950
9046
  return React__default.createElement(ColorImpl, {
8951
9047
  mClass: 'mb-[10px]',
8952
- key: item,
9048
+ key: 'color-' + i,
8953
9049
  handleChange: changeSVGTextColor,
8954
9050
  property: item,
8955
9051
  color: item
@@ -8960,10 +9056,10 @@ var Rightmenu = function Rightmenu() {
8960
9056
  className: "uppercase font-bold pt-[17px]"
8961
9057
  }, "Color in Canvas"), React__default.createElement("div", {
8962
9058
  className: "flex flex-wrap gap-x-[1rem] mt-[12px]"
8963
- }, allColor == null ? void 0 : allColor.map(function (item) {
9059
+ }, allColor == null ? void 0 : allColor.map(function (item, i) {
8964
9060
  return React__default.createElement(ColorImpl, {
8965
9061
  mClass: 'mb-[10px]',
8966
- key: item,
9062
+ key: 'color-' + i,
8967
9063
  handleChange: changeSVGTextColor,
8968
9064
  property: item,
8969
9065
  color: item
@@ -9444,7 +9540,7 @@ var SaveDesign = function SaveDesign(_ref) {
9444
9540
  while (1) switch (_context.prev = _context.next) {
9445
9541
  case 0:
9446
9542
  if (isSaving) {
9447
- _context.next = 28;
9543
+ _context.next = 30;
9448
9544
  break;
9449
9545
  }
9450
9546
  if (checkValidations()) {
@@ -9530,6 +9626,8 @@ var SaveDesign = function SaveDesign(_ref) {
9530
9626
  horizontalLine.centerH();
9531
9627
  canvas.add(horizontalLine);
9532
9628
  canvas.add(verticalLine);
9629
+ canvas.sendBackwards(horizontalLine);
9630
+ canvas.sendBackwards(verticalLine);
9533
9631
  use3dddPlus.setState({
9534
9632
  horizontalLine: horizontalLine
9535
9633
  });
@@ -9545,7 +9643,7 @@ var SaveDesign = function SaveDesign(_ref) {
9545
9643
  setIsSaving(false);
9546
9644
  console.log('ERROR in Save Logo:', ex);
9547
9645
  });
9548
- case 28:
9646
+ case 30:
9549
9647
  case "end":
9550
9648
  return _context.stop();
9551
9649
  }