diff --git a/CHANGELOG.md b/CHANGELOG.md index 3afa810..a3950dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 0.14.7 (2024-12-19) + +_New:_ + +- Added `offsetInput` property to `slitScan` effect for allowing exposing an offset variable. + ### 0.14.6 (2024-12-18) _Fixed:_ diff --git a/dist/index.cjs b/dist/index.cjs index 99c6b6c..959bc9a 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -1339,6 +1339,7 @@ function kaleidoscope ({ segments = 6, offset, rotation = 0 } = {}) { * @param {number} [params.intensity=0.1] initial intensity to use. * @param {number} [params.frequency] initial frequency to use . * @param {string} [params.direction='x'] direction to apply the slit scan effect. + * @param {string} [params.offsetInput] code to use as input for adding offset. Defaults to empty. * @returns {slitScanEffect} * * @example slitScan({intensity: 0.5, frequency: 3.0}) @@ -1349,6 +1350,7 @@ function slitScan ({ intensity = 0.1, frequency = 2.0, direction = 'x', + offsetInput = '', }) { /** * @typedef {Object} slitScanEffect @@ -1362,7 +1364,7 @@ function slitScan ({ * effect.frequency = 3.5; */ const isHorizontal = direction === 'x'; - const noiseFragPart = `gl_FragCoord.${direction} / u_resolution.${direction} * u_frequency`; + const noiseFragPart = `(gl_FragCoord.${direction} / u_resolution.${direction}${offsetInput ? `+ ${offsetInput}` : ''}) * u_frequency`; const noiseTimePart = 'u_time * 0.0001'; return { diff --git a/docs/index.html b/docs/index.html index 138913e..b22c744 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - kampos 0.14.5 | Documentation + kampos 0.14.6 | Documentation @@ -15,7 +15,7 @@

kampos

-
0.14.5
+
0.14.6
+ + params.offsetInput string? + + code to use as input for adding offset. Defaults to empty. + + + + + diff --git a/index.umd.js b/index.umd.js index bb0226f..ff70784 100644 --- a/index.umd.js +++ b/index.umd.js @@ -1343,6 +1343,7 @@ const mat3 satmat = mat3( * @param {number} [params.intensity=0.1] initial intensity to use. * @param {number} [params.frequency] initial frequency to use . * @param {string} [params.direction='x'] direction to apply the slit scan effect. + * @param {string} [params.offsetInput] code to use as input for adding offset. Defaults to empty. * @returns {slitScanEffect} * * @example slitScan({intensity: 0.5, frequency: 3.0}) @@ -1353,6 +1354,7 @@ const mat3 satmat = mat3( intensity = 0.1, frequency = 2.0, direction = 'x', + offsetInput = '', }) { /** * @typedef {Object} slitScanEffect @@ -1366,7 +1368,7 @@ const mat3 satmat = mat3( * effect.frequency = 3.5; */ const isHorizontal = direction === 'x'; - const noiseFragPart = `gl_FragCoord.${direction} / u_resolution.${direction} * u_frequency`; + const noiseFragPart = `(gl_FragCoord.${direction} / u_resolution.${direction}${offsetInput ? `+ ${offsetInput}` : ''}) * u_frequency`; const noiseTimePart = 'u_time * 0.0001'; return { diff --git a/package-lock.json b/package-lock.json index 9dd6f8b..49cc14c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kampos", - "version": "0.14.6", + "version": "0.14.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kampos", - "version": "0.14.6", + "version": "0.14.7", "license": "MIT", "devDependencies": { "@babel/core": "^7.26.0", diff --git a/package.json b/package.json index 8789062..e59643a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kampos", - "version": "0.14.6", + "version": "0.14.7", "description": "Tiny and fast effects compositor on WebGL", "registry": "https://registry.npmjs.org/", "main": "dist/index.cjs", diff --git a/src/effects/slit-scan.js b/src/effects/slit-scan.js index 9045b83..65277dc 100644 --- a/src/effects/slit-scan.js +++ b/src/effects/slit-scan.js @@ -7,6 +7,7 @@ * @param {number} [params.intensity=0.1] initial intensity to use. * @param {number} [params.frequency] initial frequency to use . * @param {string} [params.direction='x'] direction to apply the slit scan effect. + * @param {string} [params.offsetInput] code to use as input for adding offset. Defaults to empty. * @returns {slitScanEffect} * * @example slitScan({intensity: 0.5, frequency: 3.0}) @@ -17,6 +18,7 @@ export default function ({ intensity = 0.1, frequency = 2.0, direction = 'x', + offsetInput = '', }) { /** * @typedef {Object} slitScanEffect @@ -30,7 +32,7 @@ export default function ({ * effect.frequency = 3.5; */ const isHorizontal = direction === 'x'; - const noiseFragPart = `gl_FragCoord.${direction} / u_resolution.${direction} * u_frequency`; + const noiseFragPart = `(gl_FragCoord.${direction} / u_resolution.${direction}${offsetInput ? `+ ${offsetInput}` : ''}) * u_frequency`; const noiseTimePart = 'u_time * 0.0001'; return {