Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlitScan offset input #62

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:_
Expand Down
4 changes: 3 additions & 1 deletion dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -1349,6 +1350,7 @@ function slitScan ({
intensity = 0.1,
frequency = 2.0,
direction = 'x',
offsetInput = '',
}) {
/**
* @typedef {Object} slitScanEffect
Expand All @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset='utf-8'>
<title>kampos 0.14.5 | Documentation</title>
<title>kampos 0.14.6 | Documentation</title>
<meta name='description' content='Tiny and fast effects compositor on WebGL'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
Expand All @@ -15,7 +15,7 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>kampos</h3>
<div class='mb1'><code>0.14.5</code></div>
<div class='mb1'><code>0.14.6</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down Expand Up @@ -4169,6 +4169,15 @@ <h3 class='fl m0' id='effects'>



<tr>
<td class='break-word'><span class='code bold'>params.offsetInput</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?</code>
</td>
<td class='break-word'><span>code to use as input for adding offset. Defaults to empty.
</span></td>
</tr>



</tbody>
</table>

Expand Down
4 changes: 3 additions & 1 deletion index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -1353,6 +1354,7 @@ const mat3 satmat = mat3(
intensity = 0.1,
frequency = 2.0,
direction = 'x',
offsetInput = '',
}) {
/**
* @typedef {Object} slitScanEffect
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/effects/slit-scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -17,6 +18,7 @@ export default function ({
intensity = 0.1,
frequency = 2.0,
direction = 'x',
offsetInput = '',
}) {
/**
* @typedef {Object} slitScanEffect
Expand All @@ -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 {
Expand Down
Loading