thedesk/app/node_modules/@jimp/plugin-displace/es/index.js.map
2019-09-12 23:38:13 +09:00

1 line
2.9 KiB
Plaintext

{"version":3,"sources":["../src/index.js"],"names":["isNodePattern","throwError","displace","map","offset","cb","constructor","call","source","cloneQuiet","scanQuiet","bitmap","width","height","x","y","idx","displacement","data","Math","round","ids","getPixelIndex"],"mappings":";;AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,aAA1C;AAEA;;;;;;;;AAOA,gBAAe;AAAA,SAAO;AACpBC,IAAAA,QADoB,oBACXC,GADW,EACNC,MADM,EACEC,EADF,EACM;AACxB,UAAI,QAAOF,GAAP,MAAe,QAAf,IAA2BA,GAAG,CAACG,WAAJ,KAAoB,KAAKA,WAAxD,EAAqE;AACnE,eAAOL,UAAU,CAACM,IAAX,CAAgB,IAAhB,EAAsB,iCAAtB,EAAyDF,EAAzD,CAAP;AACD;;AAED,UAAI,OAAOD,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,eAAOH,UAAU,CAACM,IAAX,CAAgB,IAAhB,EAAsB,yBAAtB,EAAiDF,EAAjD,CAAP;AACD;;AAED,UAAMG,MAAM,GAAG,KAAKC,UAAL,EAAf;AACA,WAAKC,SAAL,CAAe,CAAf,EAAkB,CAAlB,EAAqB,KAAKC,MAAL,CAAYC,KAAjC,EAAwC,KAAKD,MAAL,CAAYE,MAApD,EAA4D,UAC1DC,CAD0D,EAE1DC,CAF0D,EAG1DC,GAH0D,EAI1D;AACA,YAAIC,YAAY,GAAId,GAAG,CAACQ,MAAJ,CAAWO,IAAX,CAAgBF,GAAhB,IAAuB,GAAxB,GAA+BZ,MAAlD;AACAa,QAAAA,YAAY,GAAGE,IAAI,CAACC,KAAL,CAAWH,YAAX,CAAf;AAEA,YAAMI,GAAG,GAAG,KAAKC,aAAL,CAAmBR,CAAC,GAAGG,YAAvB,EAAqCF,CAArC,CAAZ;AACA,aAAKJ,MAAL,CAAYO,IAAZ,CAAiBG,GAAjB,IAAwBb,MAAM,CAACG,MAAP,CAAcO,IAAd,CAAmBF,GAAnB,CAAxB;AACA,aAAKL,MAAL,CAAYO,IAAZ,CAAiBG,GAAG,GAAG,CAAvB,IAA4Bb,MAAM,CAACG,MAAP,CAAcO,IAAd,CAAmBF,GAAG,GAAG,CAAzB,CAA5B;AACA,aAAKL,MAAL,CAAYO,IAAZ,CAAiBG,GAAG,GAAG,CAAvB,IAA4Bb,MAAM,CAACG,MAAP,CAAcO,IAAd,CAAmBF,GAAG,GAAG,CAAzB,CAA5B;AACD,OAZD;;AAcA,UAAIhB,aAAa,CAACK,EAAD,CAAjB,EAAuB;AACrBA,QAAAA,EAAE,CAACE,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AA9BmB,GAAP;AAAA,CAAf","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Displaces the image based on the provided displacement map\n * @param {object} map the source Jimp instance\n * @param {number} offset the maximum displacement value\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n displace(map, offset, cb) {\n if (typeof map !== 'object' || map.constructor !== this.constructor) {\n return throwError.call(this, 'The source must be a Jimp image', cb);\n }\n\n if (typeof offset !== 'number') {\n return throwError.call(this, 'factor must be a number', cb);\n }\n\n const source = this.cloneQuiet();\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(\n x,\n y,\n idx\n ) {\n let displacement = (map.bitmap.data[idx] / 256) * offset;\n displacement = Math.round(displacement);\n\n const ids = this.getPixelIndex(x + displacement, y);\n this.bitmap.data[ids] = source.bitmap.data[idx];\n this.bitmap.data[ids + 1] = source.bitmap.data[idx + 1];\n this.bitmap.data[ids + 2] = source.bitmap.data[idx + 2];\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}