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