{"version":3,"file":"HueRotation.min.mjs","sources":["../../../src/filters/HueRotation.ts"],"sourcesContent":["import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport { ColorMatrix } from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = {\n  rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n  rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n *   rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n  'HueRotation',\n  HueRotationOwnProps\n> {\n  /**\n   * HueRotation value, from -1 to 1.\n   */\n  declare rotation: HueRotationOwnProps['rotation'];\n\n  static type = 'HueRotation';\n\n  static defaults = hueRotationDefaultValues;\n\n  calculateMatrix() {\n    const rad = this.rotation * Math.PI,\n      cosine = cos(rad),\n      sine = sin(rad),\n      aThird = 1 / 3,\n      aThirdSqtSin = Math.sqrt(aThird) * sine,\n      OneMinusCos = 1 - cosine;\n    this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];\n    this.matrix[0] = cosine + OneMinusCos / 3;\n    this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin;\n    this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin;\n    this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin;\n    this.matrix[6] = cosine + aThird * OneMinusCos;\n    this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin;\n    this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin;\n    this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin;\n    this.matrix[12] = cosine + aThird * OneMinusCos;\n  }\n\n  isNeutralState() {\n    return this.rotation === 0;\n  }\n\n  applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n    this.calculateMatrix();\n    super.applyTo(options);\n  }\n\n  //@ts-expect-error TS and classes with different methods\n  toObject(): { type: 'HueRotation'; rotation: number } {\n    return {\n      type: this.type,\n      rotation: this.rotation,\n    };\n  }\n}\n\nclassRegistry.setClass(HueRotation);\n"],"names":["hueRotationDefaultValues","rotation","HueRotation","ColorMatrix","calculateMatrix","rad","this","Math","PI","cosine","cos","sine","sin","aThird","aThirdSqtSin","sqrt","OneMinusCos","matrix","isNeutralState","applyTo","options","super","toObject","type","_defineProperty","classRegistry","setClass"],"mappings":"6RAUO,MAAMA,EAAgD,CAC3DC,SAAU,GAYL,MAAMC,UAAoBC,EAa/BC,eAAAA,GACE,MAAMC,EAAMC,KAAKL,SAAWM,KAAKC,GAC/BC,EAASC,EAAIL,GACbM,EAAOC,EAAIP,GACXQ,EAAS,EAAI,EACbC,EAAeP,KAAKQ,KAAKF,GAAUF,EACnCK,EAAc,EAAIP,EACpBH,KAAKW,OAAS,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,GACxEX,KAAKW,OAAO,GAAKR,EAASO,EAAc,EACxCV,KAAKW,OAAO,GAAKJ,EAASG,EAAcF,EACxCR,KAAKW,OAAO,GAAKJ,EAASG,EAAcF,EACxCR,KAAKW,OAAO,GAAKJ,EAASG,EAAcF,EACxCR,KAAKW,OAAO,GAAKR,EAASI,EAASG,EACnCV,KAAKW,OAAO,GAAKJ,EAASG,EAAcF,EACxCR,KAAKW,OAAO,IAAMJ,EAASG,EAAcF,EACzCR,KAAKW,OAAO,IAAMJ,EAASG,EAAcF,EACzCR,KAAKW,OAAO,IAAMR,EAASI,EAASG,CACtC,CAEAE,cAAAA,GACE,OAAyB,IAAlBZ,KAAKL,QACd,CAEAkB,OAAAA,CAAQC,GACNd,KAAKF,kBACLiB,MAAMF,QAAQC,EAChB,CAGAE,QAAAA,GACE,MAAO,CACLC,KAAMjB,KAAKiB,KACXtB,SAAUK,KAAKL,SAEnB,EA3CAuB,EAJWtB,EAAW,OASR,eAAasB,EAThBtB,EAAW,WAWJF,GAuCpByB,EAAcC,SAASxB"}