ag-psd 15.3.0 → 16.0.0

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.
@@ -882,7 +882,7 @@ function pointsToArray(points) {
882
882
  }
883
883
  return array;
884
884
  }
885
- function uin8ToPoints(array) {
885
+ function uint8ToPoints(array) {
886
886
  return arrayToPoints(uint8ToFloat32(array));
887
887
  }
888
888
  function hrznVrtcToPoint(desc) {
@@ -897,6 +897,56 @@ function pointToHrznVrtc(point) {
897
897
  Vrtc: unitsValue(point.y, 'y'),
898
898
  };
899
899
  }
900
+ function parseFilterFXFilter(Fltr) {
901
+ if ('puppetShapeList' in Fltr) {
902
+ return {
903
+ rigidType: Fltr.rigidType,
904
+ bounds: [
905
+ { x: Fltr.PuX0, y: Fltr.PuY0, },
906
+ { x: Fltr.PuX1, y: Fltr.PuY1, },
907
+ { x: Fltr.PuX2, y: Fltr.PuY2, },
908
+ { x: Fltr.PuX3, y: Fltr.PuY3, },
909
+ ],
910
+ puppetShapeList: Fltr.puppetShapeList.map(function (p) { return ({
911
+ rigidType: p.rigidType,
912
+ // TODO: VrsM
913
+ // TODO: VrsN
914
+ originalVertexArray: uint8ToPoints(p.originalVertexArray),
915
+ deformedVertexArray: uint8ToPoints(p.deformedVertexArray),
916
+ indexArray: Array.from(uint8ToUint32(p.indexArray)),
917
+ pinOffsets: arrayToPoints(p.pinOffsets),
918
+ posFinalPins: arrayToPoints(p.posFinalPins),
919
+ pinVertexIndices: p.pinVertexIndices,
920
+ selectedPin: p.selectedPin,
921
+ pinPosition: arrayToPoints(p.PinP),
922
+ pinRotation: p.PnRt,
923
+ pinOverlay: p.PnOv,
924
+ pinDepth: p.PnDp,
925
+ meshQuality: p.meshQuality,
926
+ meshExpansion: p.meshExpansion,
927
+ meshRigidity: p.meshRigidity,
928
+ imageResolution: p.imageResolution,
929
+ meshBoundaryPath: {
930
+ pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
931
+ shapeOperation: c.shapeOperation.split('.')[1],
932
+ paths: c.SbpL.map(function (t) { return ({
933
+ closed: t.Clsp,
934
+ points: t['Pts '].map(function (pt) { return ({
935
+ anchor: hrznVrtcToPoint(pt.Anch),
936
+ forward: hrznVrtcToPoint(pt['Fwd ']),
937
+ backward: hrznVrtcToPoint(pt['Bwd ']),
938
+ smooth: pt.Smoo,
939
+ }); }),
940
+ }); }),
941
+ }); }),
942
+ },
943
+ }); }),
944
+ };
945
+ }
946
+ else {
947
+ return {};
948
+ }
949
+ }
900
950
  function parseFilterFX(desc) {
901
951
  return {
902
952
  enabled: desc.enab,
@@ -913,52 +963,65 @@ function parseFilterFX(desc) {
913
963
  hasOptions: f.hasoptions,
914
964
  foregroundColor: parseColor(f.FrgC),
915
965
  backgroundColor: parseColor(f.BckC),
916
- filter: {
917
- rigidType: f.Fltr.rigidType,
918
- bounds: [
919
- { x: f.Fltr.PuX0, y: f.Fltr.PuY0, },
920
- { x: f.Fltr.PuX1, y: f.Fltr.PuY1, },
921
- { x: f.Fltr.PuX2, y: f.Fltr.PuY2, },
922
- { x: f.Fltr.PuX3, y: f.Fltr.PuY3, },
923
- ],
924
- puppetShapeList: f.Fltr.puppetShapeList.map(function (p) { return ({
925
- rigidType: p.rigidType,
926
- // TODO: VrsM
927
- // TODO: VrsN
928
- originalVertexArray: uin8ToPoints(p.originalVertexArray),
929
- deformedVertexArray: uin8ToPoints(p.deformedVertexArray),
930
- indexArray: Array.from(uint8ToUint32(p.indexArray)),
931
- pinOffsets: arrayToPoints(p.pinOffsets),
932
- posFinalPins: arrayToPoints(p.posFinalPins),
933
- pinVertexIndices: p.pinVertexIndices,
934
- selectedPin: p.selectedPin,
935
- pinPosition: arrayToPoints(p.PinP),
936
- pinRotation: p.PnRt,
937
- pinOverlay: p.PnOv,
938
- pinDepth: p.PnDp,
939
- meshQuality: p.meshQuality,
940
- meshExpansion: p.meshExpansion,
941
- meshRigidity: p.meshRigidity,
942
- imageResolution: p.imageResolution,
943
- meshBoundaryPath: {
944
- pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
945
- shapeOperation: c.shapeOperation.split('.')[1],
946
- paths: c.SbpL.map(function (t) { return ({
947
- closed: t.Clsp,
948
- points: t['Pts '].map(function (pt) { return ({
949
- anchor: hrznVrtcToPoint(pt.Anch),
950
- forward: hrznVrtcToPoint(pt['Fwd ']),
951
- backward: hrznVrtcToPoint(pt['Bwd ']),
952
- smooth: pt.Smoo,
953
- }); }),
954
- }); }),
955
- }); }),
956
- },
957
- }); }),
958
- },
966
+ filter: parseFilterFXFilter(f.Fltr),
959
967
  }); }),
960
968
  };
961
969
  }
970
+ function serializeFltr(filter) {
971
+ if ('puppetShapeList' in filter) {
972
+ return {
973
+ 'null': ['Ordn.Trgt'],
974
+ rigidType: filter.rigidType,
975
+ puppetShapeList: filter.puppetShapeList.map(function (p) { return ({
976
+ rigidType: p.rigidType,
977
+ VrsM: 1,
978
+ VrsN: 0,
979
+ originalVertexArray: toUint8(new Float32Array(pointsToArray(p.originalVertexArray))),
980
+ deformedVertexArray: toUint8(new Float32Array(pointsToArray(p.deformedVertexArray))),
981
+ indexArray: toUint8(new Uint32Array(p.indexArray)),
982
+ pinOffsets: pointsToArray(p.pinOffsets),
983
+ posFinalPins: pointsToArray(p.posFinalPins),
984
+ selectedPin: p.selectedPin,
985
+ pinVertexIndices: p.pinVertexIndices,
986
+ PinP: pointsToArray(p.pinPosition),
987
+ PnRt: p.pinRotation,
988
+ PnOv: p.pinOverlay,
989
+ PnDp: p.pinDepth,
990
+ meshQuality: p.meshQuality,
991
+ meshExpansion: p.meshExpansion,
992
+ meshRigidity: p.meshRigidity,
993
+ imageResolution: p.imageResolution,
994
+ meshBoundaryPath: {
995
+ pathComponents: (p.meshBoundaryPath.pathComponents || []).map(function (c) { return ({
996
+ shapeOperation: "shapeOperation.".concat(c.shapeOperation),
997
+ SbpL: (c.paths || []).map(function (path) { return ({
998
+ Clsp: path.closed,
999
+ 'Pts ': (path.points || []).map(function (pt) { return ({
1000
+ Anch: pointToHrznVrtc(pt.anchor),
1001
+ 'Fwd ': pointToHrznVrtc(pt.forward),
1002
+ 'Bwd ': pointToHrznVrtc(pt.backward),
1003
+ Smoo: pt.smooth,
1004
+ }); }),
1005
+ }); }),
1006
+ }); }),
1007
+ },
1008
+ }); }),
1009
+ PuX0: filter.bounds[0].x,
1010
+ PuX1: filter.bounds[1].x,
1011
+ PuX2: filter.bounds[2].x,
1012
+ PuX3: filter.bounds[3].x,
1013
+ PuY0: filter.bounds[0].y,
1014
+ PuY1: filter.bounds[1].y,
1015
+ PuY2: filter.bounds[2].y,
1016
+ PuY3: filter.bounds[3].y,
1017
+ };
1018
+ }
1019
+ else {
1020
+ return {
1021
+ LqMe: new Uint8Array(),
1022
+ };
1023
+ }
1024
+ }
962
1025
  function serializeFilterFX(filter) {
963
1026
  return {
964
1027
  enab: filter.enabled,
@@ -966,7 +1029,7 @@ function serializeFilterFX(filter) {
966
1029
  filterMaskEnable: filter.maskEnabled,
967
1030
  filterMaskLinked: filter.maskLinked,
968
1031
  filterMaskExtendWithWhite: filter.maskExtendWithWhite,
969
- filterFXList: filter.list.map(function (f) { return ({
1032
+ filterFXList: (filter.list || []).map(function (f) { return ({
970
1033
  'Nm ': f.name,
971
1034
  blendOptions: {
972
1035
  Opct: unitsPercent(f.opacity),
@@ -976,52 +1039,7 @@ function serializeFilterFX(filter) {
976
1039
  hasoptions: f.hasOptions,
977
1040
  FrgC: serializeColor(f.foregroundColor),
978
1041
  BckC: serializeColor(f.backgroundColor),
979
- Fltr: {
980
- 'null': ['Ordn.Trgt'],
981
- rigidType: f.filter.rigidType,
982
- puppetShapeList: f.filter.puppetShapeList.map(function (p) { return ({
983
- rigidType: p.rigidType,
984
- VrsM: 1,
985
- VrsN: 0,
986
- originalVertexArray: toUint8(new Float32Array(pointsToArray(p.originalVertexArray))),
987
- deformedVertexArray: toUint8(new Float32Array(pointsToArray(p.deformedVertexArray))),
988
- indexArray: toUint8(new Uint32Array(p.indexArray)),
989
- pinOffsets: pointsToArray(p.pinOffsets),
990
- posFinalPins: pointsToArray(p.posFinalPins),
991
- selectedPin: p.selectedPin,
992
- pinVertexIndices: p.pinVertexIndices,
993
- PinP: pointsToArray(p.pinPosition),
994
- PnRt: p.pinRotation,
995
- PnOv: p.pinOverlay,
996
- PnDp: p.pinDepth,
997
- meshQuality: p.meshQuality,
998
- meshExpansion: p.meshExpansion,
999
- meshRigidity: p.meshRigidity,
1000
- imageResolution: p.imageResolution,
1001
- meshBoundaryPath: {
1002
- pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
1003
- shapeOperation: "shapeOperation.".concat(c.shapeOperation),
1004
- SbpL: c.paths.map(function (path) { return ({
1005
- Clsp: path.closed,
1006
- 'Pts ': path.points.map(function (pt) { return ({
1007
- Anch: pointToHrznVrtc(pt.anchor),
1008
- 'Fwd ': pointToHrznVrtc(pt.forward),
1009
- 'Bwd ': pointToHrznVrtc(pt.backward),
1010
- Smoo: pt.smooth,
1011
- }); }),
1012
- }); }),
1013
- }); }),
1014
- },
1015
- }); }),
1016
- PuX0: f.filter.bounds[0].x,
1017
- PuX1: f.filter.bounds[1].x,
1018
- PuX2: f.filter.bounds[2].x,
1019
- PuX3: f.filter.bounds[3].x,
1020
- PuY0: f.filter.bounds[0].y,
1021
- PuY1: f.filter.bounds[1].y,
1022
- PuY2: f.filter.bounds[2].y,
1023
- PuY3: f.filter.bounds[3].y,
1024
- },
1042
+ Fltr: serializeFltr(f.filter),
1025
1043
  filterID: f.id,
1026
1044
  }); }),
1027
1045
  };