From 240c28365ab664da13d26423b9d31339057b782c Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 2 Nov 2019 14:33:12 +0100 Subject: [PATCH 1/5] Update dependencies --- package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index d0a36996..edada9c5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "server.js", "scripts": { - "start": "node ./hydra-server/server.js", + "start": "node ./hydra-server/server.js", "dev": "npm run start & npm run watch", "watch": "watchify ./hydra-server/app/index.js -o ./hydra-server/public/bundle.js", "build-main": "browserify ./hydra-server/app/index.js -o ./hydra-server/public/bundle.js", @@ -14,30 +14,30 @@ "author": "Olivia Jack", "license": "AGPL", "dependencies": { - "bitly": "^6.0.8", + "bitly": "^6.1.0", "browserify-middleware": "^8.1.1", - "codemirror": "^5.36.0", + "codemirror": "^5.49.2", "dotenv": "^6.2.0", "enumerate-devices": "^1.1.1", - "express": "^4.15.2", + "express": "^4.17.1", "getusermedia": "^2.0.1", "hydra-synth": "^1.0.21", - "inherits": "^2.0.3", - "meyda": "^4.1.3", - "multer": "^1.4.1", + "inherits": "^2.0.4", + "meyda": "^4.2.0", + "multer": "^1.4.2", "nedb": "^1.8.0", "p5": "^0.6.1", "raf-loop": "^1.1.3", - "rtc-patch-bay": "^1.0.0", - "simple-peer": "^9.1.2", - "socket.io": "^2.0.3", + "rtc-patch-bay": "^1.0.1", + "simple-peer": "^9.6.0", + "socket.io": "^2.3.0", "superagent": "^3.8.3", - "twilio": "^3.18.0", + "twilio": "^3.37.0", "twit": "^2.2.11", - "webrtc-adapter": "^6.3.0" + "webrtc-adapter": "^6.4.8" }, "devDependencies": { - "browserify": "^16.2.3", + "browserify": "^16.5.0", "standard": "^11.0.1", "watchify": "^3.11.1" } From a3c4a969323998997bc6354b89448acfa16d9175 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 2 Nov 2019 14:35:01 +0100 Subject: [PATCH 2/5] Add mustache package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index edada9c5..24d7e565 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "inherits": "^2.0.4", "meyda": "^4.2.0", "multer": "^1.4.2", + "mustache": "^3.1.0", "nedb": "^1.8.0", "p5": "^0.6.1", "raf-loop": "^1.1.3", From 05b69b6a619db46e6402391e402a713729561756 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 2 Nov 2019 15:04:03 +0100 Subject: [PATCH 3/5] Rewrite scripts/docs.js The funcs.md file had diverged quite a lot from what the script generated. The new script means we can again autogenerate funcs.md from the hydra-synth/src/composable-glsl-functions.js file. --- docs/funcs.md.template | 264 +++++++++++++++++++++++++++++++++++++++++ scripts/docs.js | 165 +++++++++++++++++++------- 2 files changed, 385 insertions(+), 44 deletions(-) create mode 100644 docs/funcs.md.template diff --git a/docs/funcs.md.template b/docs/funcs.md.template new file mode 100644 index 00000000..168c9be9 --- /dev/null +++ b/docs/funcs.md.template @@ -0,0 +1,264 @@ +{{! This is a mustache template for the Hydra function documentation. + The funcs.md file is generated by `scripts/docs.js` using this template. +}} +# Functions + +- [Categories of functions](#categories) +- [Complete contents of functions](#contents) + +## Categories + +- [Audio](#audio) +- [Color](#color) +- [Geometry](#geometry) +- [Global variables](#global-variables) +- [Modulators](#modulators) +- [Operators](#operators) +- [Sources](#sources) +- [Parameter sequences](#parameter-sequences) + +## Contents + +- [Audio](#audio) + - [hide](#hide) + - [setBins](#setbins) + - [setCutoff](#setcutoff) + - [setScale](#setScale) + - [setSmooth](#setSmooth) + - [show](#show) +- [Color](#color) +{{ category-toc-color }} +- [Geometry](#geometry) +{{ category-toc-geometry }} +- [Global variables](#global-variables) + - [mouse](#mouse) + - [time](#time) +- [Modulators](#modulators) +{{ category-toc-modulators }} +- [Operators](#operators) +{{ category-toc-operators }} +- [Sources](#sources) +{{ category-toc-sources }} + - [out](#out) + - [render](#render) +- [Parameter sequences](#parameter-sequences) + - [Lists as parameter sequences](#lists-as-parameter-sequences) + - [Functions on parameter sequences](#functions-on-parameter-sequences) + - [fast](#fast) + +--- + +## Audio + +Functions for manipulating audio signals. + +- [hide](#hide) +- [setBins](#setbins) +- [setCutoff](#setcutoff) +- [setScale](#setScale) +- [setSmooth](#setSmooth) +- [show](#show) + +### hide + +`.hide()` + +### setBins + +`.setBins( bins )` + +* `bins` :: integer (default `x`) + +### setCutoff + +`.setCutoff( frequency )` + +* `frequency` :: float (default `x`) + +### setScale + +`.setScale( amount )` + +* `amount` :: float (default `x`) + +### setSmooth + +`.setSmooth( amount )` + +* `amount` :: float (default `x`) + +### show + +`.show()` + +--- + +## Color + +Functions for manipulating color. + +{{ category-toc-color }} + +{{& functions-color }} + +--- + +## Geometry + +Functions for manipulating geometry. + +{{ category-toc-geometry }} + +{{& functions-geometry }} + +--- + +## Global variables + +Useful variables that are defined globally, and can be used within functions as a parameter. + +- [mouse](#mouse) +- [time](#time) + +### mouse + +`mouse` + +* `.x` :: x position of mouse +* `.y` :: y position of mouse + +#### Example + +Control the oscillator frequency with the mouse position: + +```javascript +osc(() => mouse.x).out(o0) +``` + +### time + +`time` + +* `time` :: the current time + +#### Example + +Control the oscillator using a sine wave based on the current time: + +```javascript +osc( ({time}) => Math.sin(time) ).out(o0) +``` + +--- + +## Modulators + +Functions for describing modulations of sources. + +{{ category-toc-modulators }} + +{{& functions-modulators }} + +## Operators + +Functions for performing operations on sources. + +{{ category-toc-operators }} + +{{& functions-operators }} + +--- + +## Sources + +Sources are elementary generators that output different types of visual content. + +{{ category-toc-sources }} + - [out](#out) + - [render](#render) + +{{& functions-sources }} + +### out + +`.out( buffer )` + +* `buffer` + * `osc`: `o0`, `o1`, `o2`, `o3` + * `src`: `s0`, `s1`, `s2`, `s3` + +#### Example + +```javascript +// output four oscillators to different buffers +// and then modulate them together +osc( [1,10,50,100,250,500].fast(2) ).kaleid(20).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).kaleid(19).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).kaleid(21).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 1 ) // offset + .modulate(o1,0.05) + .modulate(o2,0.05) + .modulate(o3,0.05) + .kaleid(20) + .add(noise(3,10)) + .out(o3) +render(o3) +``` + +### render + +`render( buffer )` + +* `buffer`: buffer (default `o0`) + +#### Example + +```javascript +osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset + +render(o0) // change to o1, o2, or o3 +``` + +```javascript +// see all four buffers at once +osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset +render() +``` + +--- + +## Parameter sequences + +- [Lists as parameter sequences](#lists-as-parameter-sequences) +- [Functions on parameter sequences](#functions-on-parameter-sequences) + - [fast](#fast) + +### Lists as parameter sequences + +``` +osc( + [80, 100, 200, 50], 1 ) +) +.out(o0) +``` + +### Functions on parameter sequences + +#### fast + +`fast ( amount) ` + +* `amount` :: float (default `x`) + +``` +osc( + [80, 100, 200, 50].fast(0.2), 1 ) +) +.out(o0) +``` diff --git a/scripts/docs.js b/scripts/docs.js index 913f957c..1b2c350e 100755 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -1,61 +1,138 @@ -#! /usr/bin/env node +#!/usr/bin/node +// Script to build documentation from source. const fs = require('fs') -const glslfuncs = require('hydra-synth/src/composable-glsl-functions.js') +const glslTransforms = require('hydra-synth/src/composable-glsl-functions.js') +const Mustache = require('mustache') -const [,, outPath] = process.argv +const masterTemplateFile = 'docs/funcs.md.template'; -const categories = {} -const argtypes = {} - -Object.keys(glslfuncs).forEach((k) => { - const f = glslfuncs[k] - const categoryName = f.type.charAt(0).toUpperCase() + f.type.slice(1) - categories[categoryName] = categories[categoryName] || [] - categories[categoryName].push(k) - const inputs = f.inputs || [] - inputs.forEach((i) => { - argtypes[i.type] = i.type - }) -}) - -const createlist = (items) => items.map((i) => `* ${i}`).join('\n') - -const createFuncDoc = (fname) => { - const title = `#### ${fname}` - const argnames = (glslfuncs[fname].inputs || []).map(i => `${i.name} :: ${i.type}`) - - let args - if (argnames.length > 1) { - args = `#### Args\n${createlist(argnames)}` - } else { - args = 'No Args' - } +const functionTemplate = ` +### {{ name }} + +\`{{ prototype }}\` + +{{# inputs }}* \`{{ name }}\` :: {{& type }}{{# default }} (default \`{{ default }}\`){{/ default }} +{{/inputs}} +{{# description }} + +{{& description }} +{{/ description }} +{{# example }} + +#### Example + +\`\`\`javascript +{{& example }} +\`\`\`{{/ example }}` - return `${title}\n\n${args}\n` +var categories = { + 'color': [], + 'geometry': [], + 'operators': [], + 'modulators': [], + 'sources': [], } -const createCategory = (cname) => `### ${cname} +const categoryMap = { + 'color': 'color', + 'combine': 'operators', + 'combineCoord': 'modulators', + 'coord': 'geometry', + 'src': 'sources', +} -${categories[cname].map(createFuncDoc).join('\n')} -` +function stripInitialWhitespace(paragraph) { + if (paragraph === undefined) + return undefined; -const output = `# Functions + if (paragraph[0] == '\n') + paragraph = paragraph.slice(1) -## Argument Types + let firstCharacterIndex = paragraph.match(/[^ \n]/).index; + let lines = []; + for (line of paragraph.split('\n')) { + lines.push(line.slice(firstCharacterIndex)); + } + return lines.join('\n'); +} -${createlist(Object.keys(argtypes).sort())} +function renderFunctionPrototype(name, info) { + let parameters = info['inputs'].map((input) => input.name).join(', '); + if (info['type'] == 'src') + return `${name}( ${parameters} )`; + else + return `.${name}( ${parameters} )`; +} -## Functions +function processFunctionInputs(inputs) { + return inputs.map((entry) => { + if (entry['default'] != undefined) + entry['default'] = entry['default'].toString(); + return entry; + }); +} -${Object.keys(categories).sort().map(createCategory).join('\n')} +function renderFunction(name, info) { + let view = { + 'name': name, + 'description': stripInitialWhitespace(info['description']), + 'example': stripInitialWhitespace(info['example']), + 'prototype': renderFunctionPrototype(name, info), + 'inputs': processFunctionInputs(info['inputs']), + } -` + let markdown = Mustache.render(functionTemplate, view); + return markdown; +} -fs.writeFile(outPath, output, function (err) { - if (err) { - return console.log(err) +function renderFunctions(functions) { + return functions.sort().map((name) => renderFunction(name, glslTransforms[name])).join('\n'); +} + +function renderTableOfContents(functions) { + return functions.sort().map((name) => ` - [${name}](#${name.toLowerCase()})`).join('\n'); +} + +function main(outPath) { + for (name in glslTransforms) { + method = glslTransforms[name]; + if (name[0] == '_' || method.type == 'util') + console.log(`Ignoring private function ${name}`); + else if (! method['inputs']) + console.log(`Ignoring function with no inputs ${name}`) + else { + let cat = categoryMap[method['type']]; + + categories[cat].push(name); + } } - console.log('The file was saved!') -}) + fs.readFile(masterTemplateFile, 'utf-8', (err, masterTemplateData) => { + if (err) throw err; + + let view = {}; + + for (cat in categories) { + view[`category-toc-${cat}`] = renderTableOfContents(categories[cat]) + view[`functions-${cat}`] = renderFunctions(categories[cat]) + } + + let output = '\n' + + Mustache.render(masterTemplateData, view); + + fs.writeFile(outPath, output, (err) => { + if (err) throw err; + }); + }); +}; + +const [,, outPath] = process.argv + +if (! outPath) { + console.log(`Usage: ${process.argv[1]} docs/funcs.md`); + process.exit(1); +} + +main(outPath); From 19a397604ebc6141faafb8fd0348271ce18c32cf Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sun, 3 Nov 2019 13:12:25 +0100 Subject: [PATCH 4/5] docs: Add generated funcs.md file --- docs/funcs.md | 584 +++++++++++++++++++++++++------------------------- 1 file changed, 287 insertions(+), 297 deletions(-) diff --git a/docs/funcs.md b/docs/funcs.md index c30e5830..ba459f8e 100644 --- a/docs/funcs.md +++ b/docs/funcs.md @@ -1,3 +1,5 @@ + # Functions - [Categories of functions](#categories) @@ -25,9 +27,10 @@ - [show](#show) - [Color](#color) - [brightness](#brightness) - - [contrast](#contrast) - - [color `vec4`](#color-vec4) + - [color](#color) - [colorama](#colorama) + - [contrast](#contrast) + - [hue](#hue) - [invert](#invert) - [luma](#luma) - [posterize](#posterize) @@ -38,27 +41,27 @@ - [kaleid](#kaleid) - [pixelate](#pixelate) - [repeat](#repeat) - - [repeatX](#repeatX) - - [repeatY](#repeatY) + - [repeatX](#repeatx) + - [repeatY](#repeaty) - [rotate](#rotate) - [scale](#scale) - - [scrollX](#scrollX) - - [scrollY](#scrollY) + - [scrollX](#scrollx) + - [scrollY](#scrolly) - [Global variables](#global-variables) - [mouse](#mouse) - [time](#time) - [Modulators](#modulators) - [modulate](#modulate) - - [modulateHue](#modulateHue) - - [modulateKaleid](#modulateKaleid) - - [modulatePixelate](#modulatePixelate) - - [modulateRepeat](#modulateRepeat) - - [modulateRepeatX](#modulateRepeatX) - - [modulateRepeatY](#modulateRepeatY) - - [modulateRotate](#modulateRotate) - - [modulateScale](#modulateScale) - - [modulateScrollX](#modulateScrollX) - - [modulateScrollY](#modulateScrollY) + - [modulateHue](#modulatehue) + - [modulateKaleid](#modulatekaleid) + - [modulatePixelate](#modulatepixelate) + - [modulateRepeat](#modulaterepeat) + - [modulateRepeatX](#modulaterepeatx) + - [modulateRepeatY](#modulaterepeaty) + - [modulateRotate](#modulaterotate) + - [modulateScale](#modulatescale) + - [modulateScrollX](#modulatescrollx) + - [modulateScrollY](#modulatescrolly) - [Operators](#operators) - [add](#add) - [blend](#blend) @@ -70,12 +73,12 @@ - [gradient](#gradient) - [noise](#noise) - [osc](#osc) - - [out](#out) - - [render](#render) - [shape](#shape) - [solid](#solid) - [src](#src) - [voronoi](#voronoi) + - [out](#out) + - [render](#render) - [Parameter sequences](#parameter-sequences) - [Lists as parameter sequences](#lists-as-parameter-sequences) - [Functions on parameter sequences](#functions-on-parameter-sequences) @@ -132,16 +135,18 @@ Functions for manipulating audio signals. Functions for manipulating color. -- [brightness](#brightness) -- [contrast](#contrast) -- [color `vec4`](#color-vec4) -- [colorama](#colorama) -- [invert](#invert) -- [luma](#luma) -- [posterize](#posterize) -- [saturate](#saturate) -- [shift](#shift) -- [thresh](#thresh) + - [brightness](#brightness) + - [color](#color) + - [colorama](#colorama) + - [contrast](#contrast) + - [hue](#hue) + - [invert](#invert) + - [luma](#luma) + - [posterize](#posterize) + - [saturate](#saturate) + - [shift](#shift) + - [thresh](#thresh) + ### brightness @@ -157,39 +162,15 @@ osc(20,0,2) .out(o0) ``` -### contrast - -`.contrast( amount )` - -* `amount` :: float (default `1.6`) - -Larger `amount` value makes higher contrast. - -#### Example - -```javascript -// 20Hz oscillator with contrast interpolating between 0.0-5.0 -osc(20).contrast( ({time}) => Math.sin(time) * 5 ).out(o0) -``` - -### color `vec4` - -`.color( r, g, b )` +### color -* `r` :: float -* `g` :: float -* `b` :: float +`.color( r, g, b, a )` -Colorize texture. +* `r` :: float (default `1`) +* `g` :: float (default `1`) +* `b` :: float (default `1`) +* `a` :: float (default `1`) -#### Example - -```javascript -// 20Hz oscillator source -// color sequence of Red, Green, Blue, White, Black -// output to buffer o0 -osc(20).color([1,0,0,1,0],[0,1,0,1,0],[0,0,1,1,0]).out(o0) -``` ### colorama @@ -212,16 +193,33 @@ osc(20) .out(o0) ``` +### contrast + +`.contrast( amount )` + +* `amount` :: float (default `1.6`) + +Larger amount value makes higher contrast. + +#### Example + ```javascript -// -noise(3,0.1).colorama( ({time}) => Math.sin(time/5) ).out(o0) +// 20Hz oscillator with contrast interpolating between 0.0-5.0 +osc(20).contrast( ({time}) => Math.sin(time) * 5 ).out(o0) ``` +### hue + +`.hue( hue )` + +* `hue` :: float (default `0.4`) + + ### invert `.invert( amount )` -* `amount` :: float (default `1.0`) +* `amount` :: float (default `1`) Invert color. @@ -251,7 +249,7 @@ osc(10,0,[0,0.5,1,2]).luma([0.1,0.25,0.75,1].fast(0.25),0.1).out(o0) `.posterize( bins, gamma )` -* `bins` :: float (default `3.0`) +* `bins` :: float (default `3`) * `gamma` :: float (default `0.6`) #### Example @@ -268,7 +266,7 @@ gradient(0).posterize( 3, [0.1, 0.5, 1.0, 2.0] ).out(o0) `.saturate( amount )` -* `amount` :: float (default `2.0`) +* `amount` :: float (default `2`) #### Example @@ -281,15 +279,10 @@ osc(10,0,1).saturate( ({time}) => Math.sin(time) * 10 ).out() `.shift( r, g, b, a )` * `r` :: float (default `0.5`) -* `g` :: float (default `0.5`) -* `b` :: float (default `0.5`) -* `a` :: float (default `0.5`) +* `g` :: float (default `0`) +* `b` :: float (default `0`) +* `a` :: float (default `0`) -#### Example - -```javascript - -``` ### thresh @@ -315,21 +308,22 @@ noise(3,0.1) Functions for manipulating geometry. -- [kaleid](#kaleid) -- [pixelate](#pixelate) -- [repeat](#repeat) -- [repeatX](#repeatX) -- [repeatY](#repeatY) -- [rotate](#rotate) -- [scale](#scale) -- [scrollX](#scrollX) -- [scrollY](#scrollY) + - [kaleid](#kaleid) + - [pixelate](#pixelate) + - [repeat](#repeat) + - [repeatX](#repeatx) + - [repeatY](#repeaty) + - [rotate](#rotate) + - [scale](#scale) + - [scrollX](#scrollx) + - [scrollY](#scrolly) + ### kaleid `.kaleid( nSides )` -* `nSides` :: float (default `4.0`) +* `nSides` :: float (default `4`) Kaleidoscope effect with `nSides` repetition. @@ -341,10 +335,10 @@ osc(25,-0.1,0.5).kaleid(50).out(o0) ### pixelate -`.pixelate( x, y )` +`.pixelate( pixelX, pixelY )` -* `pixelX` :: float (default `20.0`) -* `pixelY` :: float (default `20.0`) +* `pixelX` :: float (default `20`) +* `pixelY` :: float (default `20`) Pixelate texture with `pixelX` segments and `pixelY` segments. @@ -367,10 +361,10 @@ noise() `.repeat( repeatX, repeatY, offsetX, offsetY )` -* `repeatX` :: float (default `3.0`) -* `repeatY` :: float (default `3.0`) -* `offsetX` :: float (default `0.0`) -* `offsetY` :: float (default `0.0`) +* `repeatX` :: float (default `3`) +* `repeatY` :: float (default `3`) +* `offsetX` :: float (default `0`) +* `offsetY` :: float (default `0`) #### Example @@ -390,8 +384,8 @@ shape(1.25,0.5,0.25) `.repeatX( reps, offset )` -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.0`) +* `reps` :: float (default `3`) +* `offset` :: float (default `0`) #### Example @@ -409,8 +403,8 @@ osc(5,0,1) `.repeatY( reps, offset )` -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.0`) +* `reps` :: float (default `3`) +* `offset` :: float (default `0`) #### Example @@ -427,8 +421,8 @@ osc(5,0,1) `.rotate( angle, speed )` -* `angle` :: float (default `10.0`) -* `speed` :: float (default `0.0`) +* `angle` :: float (default `10`) +* `speed` :: float (default `0`) Rotate texture. @@ -438,17 +432,19 @@ Rotate texture. osc(50).rotate( ({time}) => time%360 ).out(o0) osc(10,1,1) - .rotate( ({time}) => time%360, ({time}) => Math.sin(time*0.1)*0.05 ) - .out(o0) + .rotate( ({time}) => time%360, ({time}) => Math.sin(time*0.1)*0.05 ) + .out(o0) ``` ### scale -`.scale( size, xMult, yMult )` +`.scale( amount, xMult, yMult, offsetX, offsetY )` -* `size` :: float (default `1.5`) -* `xMult` :: float (default `1.0`) -* `yMult` :: float (default `1.0`) +* `amount` :: float (default `1.5`) +* `xMult` :: float (default `1`) +* `yMult` :: float (default `1`) +* `offsetX` :: float (default `0.5`) +* `offsetY` :: float (default `0.5`) Scale texture. @@ -472,7 +468,7 @@ shape().scale(1.5,[0.25,0.5,0.75,1].fast(0.25),[3,2,1]) `.scrollX( scrollX, speed )` * `scrollX` :: float (default `0.5`) -* `speed` :: float (default `0.0`) +* `speed` :: float (default `0`) #### Example @@ -500,7 +496,7 @@ gradient(0.125) `.scrollY( scrollY, speed )` * `scrollY` :: float (default `0.5`) -* `speed` :: float (default `0.0`) +* `speed` :: float (default `0`) #### Example @@ -567,30 +563,32 @@ osc( ({time}) => Math.sin(time) ).out(o0) Functions for describing modulations of sources. -- [modulate](#modulate) -- [modulateHue](#modulateHue) -- [modulateKaleid](#modulateKaleid) -- [modulatePixelate](#modulatePixelate) -- [modulateRepeat](#modulateRepeat) -- [modulateRepeatX](#modulateRepeatX) -- [modulateRepeatY](#modulateRepeatY) -- [modulateRotate](#modulateRotate) -- [modulateScale](#modulateScale) -- [modulateScrollX](#modulateScrollX) -- [modulateScrollY](#modulateScrollY) + - [modulate](#modulate) + - [modulateHue](#modulatehue) + - [modulateKaleid](#modulatekaleid) + - [modulatePixelate](#modulatepixelate) + - [modulateRepeat](#modulaterepeat) + - [modulateRepeatX](#modulaterepeatx) + - [modulateRepeatY](#modulaterepeaty) + - [modulateRotate](#modulaterotate) + - [modulateScale](#modulatescale) + - [modulateScrollX](#modulatescrollx) + - [modulateScrollY](#modulatescrolly) + ### modulate `.modulate( texture, amount )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 * `amount` :: float (default `0.1`) -Modulate texture. -More about modulation at: https://lumen-app.com/guide/modulation/ +Modulate texture. + +More about modulation at: + +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). #### Example @@ -600,41 +598,35 @@ voronoi() .color(0.9,0.25,0.15) .rotate(({time})=>(time%360)/2) .modulate(osc(25,0.1,0.5) - .kaleid(50) - .scale(({time})=>Math.sin(time*1)*0.5+1) - .modulate(noise(0.6,0.5)), - 0.5) + .kaleid(50) + .scale(({time})=>Math.sin(time*1)*0.5+1) + .modulate(noise(0.6,0.5)), + 0.5) .out(o0) ``` ### modulateHue -`.modulateHue( color, amount )` +`.modulateHue( texture, amount )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `1.0`) +* `texture` :: vec4 +* `amount` :: float (default `1`) -Changes coordinates based on hue of second input. -Based on:https://www.shadertoy.com/view/XtcSWM +Changes coordinates based on hue of second input. Based on: https://www.shadertoy.com/view/XtcSWM -#### Example +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). -```javascript - -``` ### modulateKaleid -`.modulateKaleid( nSides )` +`.modulateKaleid( texture, nSides )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `nSides` :: float (default `4.0`) +* `texture` :: vec4 +* `nSides` :: float (default `4`) + +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). See also: [`kaleid`](#kaleid). @@ -651,14 +643,14 @@ osc(9,-0.1,0.1) ### modulatePixelate -`.modulatePixelate( multiple, offset )` +`.modulatePixelate( texture, multiple, offset )` + +* `texture` :: vec4 +* `multiple` :: float (default `10`) +* `offset` :: float (default `3`) -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `10.0`) -* `offset` :: float (default `3.0`) +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). See also: [`pixelate`](#pixelate) @@ -675,15 +667,15 @@ voronoi(10,1,5).brightness(()=>Math.random()*0.15) `.modulateRepeat( texture, repeatX, repeatY, offsetX, offsetY )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `repeatX` :: float (default `3.0`) -* `repeatY` :: float (default `3.0`) +* `texture` :: vec4 +* `repeatX` :: float (default `3`) +* `repeatY` :: float (default `3`) * `offsetX` :: float (default `0.5`) * `offsetY` :: float (default `0.5`) +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -698,13 +690,13 @@ shape(4,0.9) `.modulateRepeatX( texture, reps, offset )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) +* `texture` :: vec4 +* `reps` :: float (default `3`) * `offset` :: float (default `0.5`) +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -720,13 +712,13 @@ shape(4,0.9) `.modulateRepeatY( texture, reps, offset )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) +* `texture` :: vec4 +* `reps` :: float (default `3`) * `offset` :: float (default `0.5`) +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -742,12 +734,12 @@ shape(4,0.9) `.modulateRotate( texture, multiple, offset )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `1.0`) -* `offset` :: float (default `0.0`) +* `texture` :: vec4 +* `multiple` :: float (default `1`) +* `offset` :: float (default `0`) + +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). See also: [`rotate`](#rotate) @@ -763,16 +755,16 @@ voronoi(100,3,5) ### modulateScale -`.modulateScale( multiple, offset )` +`.modulateScale( texture, multiple, offset )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `1.0`) -* `offset` :: float (default `1.0`) +* `texture` :: vec4 +* `multiple` :: float (default `1`) +* `offset` :: float (default `1`) -See also: [`scale`](#scale) +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + +See also: [`scale`](#scale). #### Example @@ -785,16 +777,16 @@ gradient(5).repeat(50,50).kaleid([3,5,7,9].fast(0.5)) ### modulateScrollX -`.modulateScrollX( multiple, scrollX, speed )` +`.modulateScrollX( texture, scrollX, speed )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 * `scrollX` :: float (default `0.5`) -* `speed` :: float (default `0.0`) +* `speed` :: float (default `0`) + +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). -See also: [`scrollX`](#scrollx) +See also: [`scrollX`](#scrollX) #### Example @@ -812,14 +804,14 @@ voronoi(25,0,0) ### modulateScrollY -`.modulateScrollY( multiple, scrollX, speed )` +`.modulateScrollY( texture, scrollY, speed )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 * `scrollY` :: float (default `0.5`) -* `speed` :: float (default `0.0`) +* `speed` :: float (default `0`) + +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). See also: [`scrollY`](#scrollY) @@ -837,31 +829,30 @@ voronoi(25,0,0) .out(o0) ``` ---- - ## Operators Functions for performing operations on sources. -- [add](#add) -- [blend](#blend) -- [diff](#diff) -- [layer](#layer) -- [mask](#mask) -- [mult](#mult) + - [add](#add) + - [blend](#blend) + - [diff](#diff) + - [layer](#layer) + - [mask](#mask) + - [mult](#mult) + ### add `.add( texture, amount )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 * `amount` :: float (default `0.5`) Add textures. +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -874,14 +865,14 @@ osc(9,0.1,1).add(osc(13,0.5,5)).out() `.blend( texture, amount )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 * `amount` :: float (default `0.5`) Blend textures. +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -894,13 +885,13 @@ osc(9,0.1,1).blend(osc(13,0.5,5)).out() `.diff( texture )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 Return difference of textures. +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -918,13 +909,13 @@ osc(1,1,2) `.layer( texture )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) +* `texture` :: vec4 Overlay texture based on alpha value. + The `texture` parameter can be any kind of [source](#sources), for + example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -935,11 +926,8 @@ solid(1,0,0,1).layer(shape(4).color(0,1,0,({time})=>Math.sin(time*2))).out() `.mask( texture, reps, offset )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) +* `texture` :: vec4 +* `reps` :: float (default `3`) * `offset` :: float (default `0.5`) #### Example @@ -961,14 +949,14 @@ osc(10,-0.25,1).color(0,0,1).saturate(2).kaleid(50) `.mult( texture, amount )` -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `1.0`) +* `texture` :: vec4 +* `amount` :: float (default `1`) Multiply images and blend with the texture by `amount`. +The `texture` parameter can be any kind of [source](#sources), for +example a [`color`](#color), [`src`](#src), or [`shape`](#shape). + #### Example ```javascript @@ -981,21 +969,22 @@ osc(9,0.1,2).mult(osc(13,0.5,5)).out() Sources are elementary generators that output different types of visual content. -- [gradient](#gradient) -- [noise](#noise) -- [osc](#osc) -- [out](#out) -- [render](#render) -- [shape](#shape) -- [solid](#solid) -- [src](#src) -- [voronoi](#voronoi) + - [gradient](#gradient) + - [noise](#noise) + - [osc](#osc) + - [shape](#shape) + - [solid](#solid) + - [src](#src) + - [voronoi](#voronoi) + - [out](#out) + - [render](#render) + ### gradient `gradient( speed )` -* `speed` :: float (default `x`) +* `speed` :: float (default `0`) #### Example @@ -1008,7 +997,7 @@ gradient([1,2,4]).out(o0) `noise( scale, offset )` -* `scale` :: int (default `10.0`) +* `scale` :: float (default `10`) * `offset` :: float (default `0.1`) Generate [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise). @@ -1018,16 +1007,16 @@ Generate [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise). ```javascript // noise interpolating between different scales and offsets noise( ({time}) => Math.sin(time/10)*50 , ({time}) => Math.sin(time/2)/500 ) - .out(o0) +.out(o0) ``` ### osc `osc( frequency, sync, offset )` -* `frequency` :: float (default `60.0`) +* `frequency` :: float (default `60`) * `sync` :: float (default `0.1`) -* `offset` :: float (default `0.0`) +* `offset` :: float (default `0`) #### Example @@ -1045,63 +1034,11 @@ osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o0) osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o0) ``` -### out - -`.out( buffer )` - -* `buffer` - * `osc`: `o0`, `o1`, `o2`, `o3` - * `src`: `s0`, `s1`, `s2`, `s3` - -#### Example - -```javascript -// output four oscillators to different buffers -// and then modulate them together -osc( [1,10,50,100,250,500].fast(2) ).kaleid(20).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).kaleid(19).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).kaleid(21).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 1 ) // offset - .modulate(o1,0.05) - .modulate(o2,0.05) - .modulate(o3,0.05) - .kaleid(20) - .add(noise(3,10)) - .out(o3) -render(o3) -``` - -### render - -`render( buffer )` - -* `buffer`: buffer (default `o0`) - -#### Example - -```javascript -osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset - -render(o0) // change to o1, o2, or o3 -``` - -```javascript -// see all four buffers at once -osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset -render() -``` - ### shape -`shape( sides, radius, smoothing)` +`shape( sides, radius, smoothing )` -* `sides` :: int (default `3.0`) +* `sides` :: float (default `3`) * `radius` :: float (default `0.3`) * `smoothing` :: float (default `0.01`) @@ -1126,10 +1063,10 @@ shape(5,0.5,0.1).repeat(19,19) `solid( r, g, b, a )` -* `r` :: float (default `0.0`) -* `g` :: float (default `0.0`) -* `b` :: float (default `0.0`) -* `a` :: float (default `1.0`) +* `r` :: float (default `0`) +* `g` :: float (default `0`) +* `b` :: float (default `0`) +* `a` :: float (default `1`) #### Example @@ -1146,6 +1083,7 @@ solid([1,0,0],[0,1,0],[0,0,1],1).out(o0) See `hydra-examples` repository + ### voronoi `voronoi( scale, speed, blending )` @@ -1166,6 +1104,58 @@ voronoi(5,0.3,0.3).out(o0) voronoi(25,2,10).color(1,1,0).brightness(0.15).out(o0) ``` +### out + +`.out( buffer )` + +* `buffer` + * `osc`: `o0`, `o1`, `o2`, `o3` + * `src`: `s0`, `s1`, `s2`, `s3` + +#### Example + +```javascript +// output four oscillators to different buffers +// and then modulate them together +osc( [1,10,50,100,250,500].fast(2) ).kaleid(20).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).kaleid(19).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).kaleid(21).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 1 ) // offset + .modulate(o1,0.05) + .modulate(o2,0.05) + .modulate(o3,0.05) + .kaleid(20) + .add(noise(3,10)) + .out(o3) +render(o3) +``` + +### render + +`render( buffer )` + +* `buffer`: buffer (default `o0`) + +#### Example + +```javascript +osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset + +render(o0) // change to o1, o2, or o3 +``` + +```javascript +// see all four buffers at once +osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency +osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 +osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync +osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset +render() +``` + --- ## Parameter sequences From 30409177d8701fa32287b40dd7fd580faa2a2f4d Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sun, 3 Nov 2019 13:16:49 +0100 Subject: [PATCH 5/5] docs: Remove separate .md files to avoid duplicating info The location for function documentation is now hydra-synth.git/src/composable-glsl-functions.js. --- docs/funcs_audio.md | 42 ----- docs/funcs_color.md | 180 -------------------- docs/funcs_geometry.md | 211 ----------------------- docs/funcs_modulators.md | 273 ------------------------------ docs/funcs_operators.md | 135 --------------- docs/funcs_sources.md | 186 -------------------- docs/funsc_parameter-sequences.md | 29 ---- 7 files changed, 1056 deletions(-) delete mode 100644 docs/funcs_audio.md delete mode 100644 docs/funcs_color.md delete mode 100644 docs/funcs_geometry.md delete mode 100644 docs/funcs_modulators.md delete mode 100644 docs/funcs_operators.md delete mode 100644 docs/funcs_sources.md delete mode 100644 docs/funsc_parameter-sequences.md diff --git a/docs/funcs_audio.md b/docs/funcs_audio.md deleted file mode 100644 index 7d9aae6d..00000000 --- a/docs/funcs_audio.md +++ /dev/null @@ -1,42 +0,0 @@ -## Audio - -Functions for manipulating audio signals. - -- [hide](#hide) -- [setBins](#setbins) -- [setCutoff](#setcutoff) -- [setScale](#setScale) -- [setSmooth](#setSmooth) -- [show](#show) - -### hide - -`.hide()` - -### setBins - -`.setBins( bins )` - -* `bins` :: integer (default `x`) - -### setCutoff - -`.setCutoff( frequency )` - -* `frequency` :: float (default `x`) - -### setScale - -`.setScale( amount )` - -* `amount` :: float (default `x`) - -### setSmooth - -`.setSmooth( amount )` - -* `amount` :: float (default `x`) - -### show - -`.show()` diff --git a/docs/funcs_color.md b/docs/funcs_color.md deleted file mode 100644 index 79cfc061..00000000 --- a/docs/funcs_color.md +++ /dev/null @@ -1,180 +0,0 @@ -## Color - -Functions for manipulating color. - -- [brightness](#brightness) -- [contrast](#contrast) -- [color `vec4`](#color-vec4) -- [colorama](#colorama) -- [invert](#invert) -- [luma](#luma) -- [posterize](#posterize) -- [saturate](#saturate) -- [shift](#shift) -- [thresh](#thresh) - -### brightness - -`.brightness( amount )` - -* `amount` :: float (default `0.4`) - -#### Example - -```javascript -osc(20,0,2) - .brightness( ({time}) => Math.sin(time) ) - .out(o0) -``` - -### contrast - -`.contrast( amount )` - -* `amount` :: float (default `1.6`) - -Larger `amount` value makes higher contrast. - -#### Example - -```javascript -// 20Hz oscillator with contrast interpolating between 0.0-5.0 -osc(20).contrast( ({time}) => Math.sin(time) * 5 ).out(o0) -``` - -### color `vec4` - -`.color( r, g, b )` - -* `r` :: float -* `g` :: float -* `b` :: float - -Colorize texture. - -#### Example - -```javascript -// 20Hz oscillator source -// color sequence of Red, Green, Blue, White, Black -// output to buffer o0 -osc(20).color([1,0,0,1,0],[0,1,0,1,0],[0,0,1,1,0]).out(o0) -``` - -### colorama - -`.colorama( amount )` - -* `amount` :: float (default `0.005`) - -Shift HSV values. - -#### Example - -```javascript -// 20Hz oscillator source -// color sequence of Red, Green, Blue, White, Black -// colorama sequence of 0.005, 0.5, 1.0 at 1/8 speed -// output to buffer o0 -osc(20) - .color([1,0,0,1,0],[0,1,0,1,0],[0,0,1,1,0]) - .colorama([0.005,0.33,0.66,1.0].fast(0.125)) - .out(o0) -``` - -```javascript -// -noise(3,0.1).colorama( ({time}) => Math.sin(time/5) ).out(o0) -``` - -### invert - -`.invert( amount )` - -* `amount` :: float (default `1.0`) - -Invert color. - -#### Example - -```javascript -solid(1,1,1).invert([0,1]).out(o0) -``` - -### luma - -`.luma( threshold, tolerance )` - -* `threshold` :: float (default `0.5`) -* `tolerance` :: float (default `0.1`) - -#### Example - -```javascript -// default -osc(10,0,1).luma(0.5,0.1).out(o0) - -osc(10,0,[0,0.5,1,2]).luma([0.1,0.25,0.75,1].fast(0.25),0.1).out(o0) -``` - -### posterize - -`.posterize( bins, gamma )` - -* `bins` :: float (default `3.0`) -* `gamma` :: float (default `0.6`) - -#### Example - -```javascript -// static gradient posterized, varying bins -gradient(0).posterize( [1, 5, 15, 30] , 0.5 ).out(o0) - -// static gradient posterized, varying gamma -gradient(0).posterize( 3, [0.1, 0.5, 1.0, 2.0] ).out(o0) -``` - -### saturate - -`.saturate( amount )` - -* `amount` :: float (default `2.0`) - -#### Example - -```javascript -osc(10,0,1).saturate( ({time}) => Math.sin(time) * 10 ).out() -``` - -### shift - -`.shift( r, g, b, a )` - -* `r` :: float (default `0.5`) -* `g` :: float (default `0.5`) -* `b` :: float (default `0.5`) -* `a` :: float (default `0.5`) - -#### Example - -```javascript - -``` - -### thresh - -`.thresh( threshold, tolerance )` - -* `threshold` :: float (default `0.5`) -* `tolerance` :: float (default `0.04`) - -#### Example - -```javascript -// default -noise(3,0.1).thresh(0.5,0.04).out(o0) - -noise(3,0.1) - .thresh( ({time})=>Math.sin(time/2) , [0.04,0.25,0.75,1].fast(0.25) ) - .out(o0) -``` diff --git a/docs/funcs_geometry.md b/docs/funcs_geometry.md deleted file mode 100644 index 2bc7545d..00000000 --- a/docs/funcs_geometry.md +++ /dev/null @@ -1,211 +0,0 @@ -## Geometry - -Functions for manipulating geometry. - -- [kaleid](#kaleid) -- [pixelate](#pixelate) -- [repeat](#repeat) -- [repeatX](#repeatX) -- [repeatY](#repeatY) -- [rotate](#rotate) -- [scale](#scale) -- [scrollX](#scrollX) -- [scrollY](#scrollY) - -### kaleid - -`.kaleid( nSides )` - -* `nSides` :: float (default `4.0`) - -Kaleidoscope effect with `nSides` repetition. - -#### Example - -```javascript -osc(25,-0.1,0.5).kaleid(50).out(o0) -``` - -### pixelate - -`.pixelate( x, y )` - -* `pixelX` :: float (default `20.0`) -* `pixelY` :: float (default `20.0`) - -Pixelate texture with `pixelX` segments and `pixelY` segments. - -#### Example - -```javascript -// default -noise().pixelate(20,20).out(o0) - -noise() - .mult(osc(10,0.25,1)) - .scrollY(1,0.25) - .pixelate([100,40,20,70].fast(0.25)) - .modulateRotate(src(o0).scale(0.5),0.125) - .diff(src(o0).rotate([-0.05,0.05].fast(0.125))) - .out(o0) -``` - -### repeat - -`.repeat( repeatX, repeatY, offsetX, offsetY )` - -* `repeatX` :: float (default `3.0`) -* `repeatY` :: float (default `3.0`) -* `offsetX` :: float (default `0.0`) -* `offsetY` :: float (default `0.0`) - -#### Example - -```javascript -// default -shape().repeat(3.0, 3.0, 0.0, 0.0).out() - -// dogtooth factory -shape(1.25,0.5,0.25) - .repeat(3, 3) - .scale(2) - .repeat(5, 5, ({time}) => Math.sin(time), ({time}) => Math.sin(time/2)) - .out(o0) -``` - -### repeatX - -`.repeatX( reps, offset )` - -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.0`) - -#### Example - -```javascript -// default -shape().repeatX(3.0, 0.0).out() - -osc(5,0,1) - .rotate(1.57) - .repeatX([1,2,5,10], ({time}) => Math.sin(time)) - .out() -``` - -### repeatY - -`.repeatY( reps, offset )` - -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.0`) - -#### Example - -```javascript -// default -shape().repeatY(3.0, 0.0).out() - -osc(5,0,1) - .repeatY([1,2,5,10], ({time}) => Math.sin(time)) - .out() -``` - -### rotate - -`.rotate( angle, speed )` - -* `angle` :: float (default `10.0`) -* `speed` :: float (default `0.0`) - -Rotate texture. - -#### Example - -```javascript -osc(50).rotate( ({time}) => time%360 ).out(o0) - -osc(10,1,1) - .rotate( ({time}) => time%360, ({time}) => Math.sin(time*0.1)*0.05 ) - .out(o0) -``` - -### scale - -`.scale( size, xMult, yMult )` - -* `size` :: float (default `1.5`) -* `xMult` :: float (default `1.0`) -* `yMult` :: float (default `1.0`) - -Scale texture. - -#### Example - -```javascript -// default -shape().scale(1.5,1,1).out() - -shape().scale(1.5,[0.25,0.5,0.75,1].fast(0.25),[3,2,1]) - .invert([0,1].fast(0.25)) - .kaleid(5) - .kaleid(12) - .scale( ({time})=>Math.sin(time/5)*0.5 ) - .rotate(1,1) - .out(o0) -``` - -### scrollX - -`.scrollX( scrollX, speed )` - -* `scrollX` :: float (default `0.5`) -* `speed` :: float (default `0.0`) - -#### Example - -```javascript -// default -osc(10,0,1).scrollX(0.5,0).out() - -// x position -osc(10,0,1).scrollX([0,0.25,0.5,0.75,1].fast(4),0).out() - -// scroll speed -gradient(1).scrollX(0, ({time}) => Math.sin(time*0.05)*0.05 ).out() - -gradient(0.125) - .scrollX(0, ({time}) => Math.sin(time*0.05)*0.05 ) - .scrollY(0, ({time}) => Math.sin(time*0.01)*-0.07 ) - .pixelate([5,2,10],[15,8]) - .scale(0.15) - .modulate(noise(1,0.25)) - .out() -``` - -### scrollY - -`.scrollY( scrollY, speed )` - -* `scrollY` :: float (default `0.5`) -* `speed` :: float (default `0.0`) - -#### Example - -```javascript -// default -osc(10,0,1).scrollY(0.5,0).out() - -// y position -osc(10,0,1).scrollY([0,0.25,0.5,0.75,1].fast(4),0).out() - -// scroll speed -gradient(1).scrollY(0, ({time}) => Math.sin(time*0.05)*0.05 ).out() - -gradient(0.125) - .scrollX(0, ({time}) => Math.sin(time*0.05)*0.05 ) - .scrollY(0, ({time}) => Math.sin(time*0.01)*-0.07 ) - .pixelate([5,2,10],[15,8]) - .scale(0.15) - .modulate(noise(1,0.25)) - .out() -``` diff --git a/docs/funcs_modulators.md b/docs/funcs_modulators.md deleted file mode 100644 index 2bdbf612..00000000 --- a/docs/funcs_modulators.md +++ /dev/null @@ -1,273 +0,0 @@ -## Modulators - -Functions for describing modulations of sources. - -- [modulate](#modulate) -- [modulateHue](#modulateHue) -- [modulateKaleid](#modulateKaleid) -- [modulatePixelate](#modulatePixelate) -- [modulateRepeat](#modulateRepeat) -- [modulateRepeatX](#modulateRepeatX) -- [modulateRepeatY](#modulateRepeatY) -- [modulateRotate](#modulateRotate) -- [modulateScale](#modulateScale) -- [modulateScrollX](#modulateScrollX) -- [modulateScrollY](#modulateScrollY) - -### modulate - -`.modulate( texture, amount )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `0.1`) - -Modulate texture. -More about modulation at: https://lumen-app.com/guide/modulation/ - -#### Example - -```javascript -// chocolate whirlpool -voronoi() - .color(0.9,0.25,0.15) - .rotate(({time})=>(time%360)/2) - .modulate(osc(25,0.1,0.5) - .kaleid(50) - .scale(({time})=>Math.sin(time*1)*0.5+1) - .modulate(noise(0.6,0.5)), - 0.5) - .out(o0) -``` - -### modulateHue - -`.modulateHue( color, amount )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `1.0`) - -Changes coordinates based on hue of second input. -Based on:https://www.shadertoy.com/view/XtcSWM - -#### Example - -```javascript - -``` - -### modulateKaleid - -`.modulateKaleid( nSides )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `nSides` :: float (default `4.0`) - -See also: [`kaleid`](#kaleid). - -#### Example - -```javascript -osc(9,-0.1,0.1) - .modulateKaleid(osc(11,0.5,0),50) - .scale(0.1,0.3) - .modulate(noise(5,0.1)) - .mult(solid(1,1,0.3)) - .out(o0) -``` - -### modulatePixelate - -`.modulatePixelate( multiple, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `10.0`) -* `offset` :: float (default `3.0`) - -See also: [`pixelate`](#pixelate) - -#### Example - -```javascript -// what lies beneath -voronoi(10,1,5).brightness(()=>Math.random()*0.15) - .modulatePixelate(noise(25,0.5),100) - .out(o0) -``` - -### modulateRepeat - -`.modulateRepeat( texture, repeatX, repeatY, offsetX, offsetY )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `repeatX` :: float (default `3.0`) -* `repeatY` :: float (default `3.0`) -* `offsetX` :: float (default `0.5`) -* `offsetY` :: float (default `0.5`) - -#### Example - -```javascript -// default -shape(4,0.9) - .mult(osc(3,0.5,1)) - .modulateRepeat(osc(10), 3.0, 3.0, 0.5, 0.5) - .out(o0) -``` - -### modulateRepeatX - -`.modulateRepeatX( texture, reps, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.5`) - -#### Example - -```javascript -// straight lines illusion -shape(4,0.9) - .mult(osc(4,0.25,1)) - .modulateRepeatX(osc(10), 5.0, ({time}) => Math.sin(time) * 5) - .scale(1,0.5,0.05) - .out(o0) -``` - -### modulateRepeatY - -`.modulateRepeatY( texture, reps, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.5`) - -#### Example - -```javascript -// morphing grid -shape(4,0.9) - .mult(osc(4,0.25,1)) - .modulateRepeatY(osc(10), 5.0, ({time}) => Math.sin(time) * 5) - .scale(1,0.5,0.05) - .out(o0) -``` - -### modulateRotate - -`.modulateRotate( texture, multiple, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `1.0`) -* `offset` :: float (default `0.0`) - -See also: [`rotate`](#rotate) - -#### Example - -```javascript -// wormhole -voronoi(100,3,5) - .modulateRotate(osc(1,0.5,0).kaleid(50).scale(0.5),15,0) - .mult(osc(50,-0.1,8).kaleid(9)) - .out(o0) -``` - -### modulateScale - -`.modulateScale( multiple, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `multiple` :: float (default `1.0`) -* `offset` :: float (default `1.0`) - -See also: [`scale`](#scale) - -#### Example - -```javascript -// cosmic radiation -gradient(5).repeat(50,50).kaleid([3,5,7,9].fast(0.5)) - .modulateScale(osc(4,-0.5,0).kaleid(50).scale(0.5),15,0) - .out(o0) -``` - -### modulateScrollX - -`.modulateScrollX( multiple, scrollX, speed )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `scrollX` :: float (default `0.5`) -* `speed` :: float (default `0.0`) - -See also: [`scrollX`](#scrollx) - -#### Example - -```javascript -// default -voronoi(25,0,0) - .modulateScrollX(osc(10),0.5,0) - .out(o0) - -// different scroll and speed -voronoi(25,0,0) - .modulateScrollX(osc(10),0.5,0.25) - .out(o0) -``` - -### modulateScrollY - -`.modulateScrollY( multiple, scrollX, speed )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `scrollY` :: float (default `0.5`) -* `speed` :: float (default `0.0`) - -See also: [`scrollY`](#scrollY) - -#### Example - -```javascript -// default -voronoi(25,0,0) - .modulateScrollY(osc(10),0.5,0) - .out(o0) - -// different scroll and speed -voronoi(25,0,0) - .modulateScrollY(osc(10),0.5,0.25) - .out(o0) -``` diff --git a/docs/funcs_operators.md b/docs/funcs_operators.md deleted file mode 100644 index 6189782c..00000000 --- a/docs/funcs_operators.md +++ /dev/null @@ -1,135 +0,0 @@ -## Operators - -Functions for performing operations on sources. - -- [add](#add) -- [blend](#blend) -- [diff](#diff) -- [layer](#layer) -- [mask](#mask) -- [mult](#mult) - -### add - -`.add( texture, amount )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `0.5`) - -Add textures. - -#### Example - -```javascript -shape().scale(0.5).add(shape(4),[0,0.25,0.5,0.75,1]).out() - -osc(9,0.1,1).add(osc(13,0.5,5)).out() -``` - -### blend - -`.blend( texture, amount )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `0.5`) - -Blend textures. - -#### Example - -```javascript -shape().scale(0.5).blend(shape(4),[0,0.25,0.5,0.75,1]).out() - -osc(9,0.1,1).blend(osc(13,0.5,5)).out() -``` - -### diff - -`.diff( texture )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) - -Return difference of textures. - -#### Example - -```javascript -osc(9,0.1,1).diff(osc(13,0.5,5)).out() - -osc(1,1,2) - .diff(shape(6,1.1,0.01) - .scale(({time})=>Math.sin(time)*0.05 + 0.9) - .kaleid(15) - .rotate(({time})=>time%360)) - .out() -``` - -### layer - -`.layer( texture )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) - -Overlay texture based on alpha value. - -#### Example - -```javascript -solid(1,0,0,1).layer(shape(4).color(0,1,0,({time})=>Math.sin(time*2))).out() -``` - -### mask - -`.mask( texture, reps, offset )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `reps` :: float (default `3.0`) -* `offset` :: float (default `0.5`) - -#### Example - -```javascript -// default -gradient(5).mask(voronoi(),3,0.5).invert([0,1]).out() - -// algae pulse -osc(10,-0.25,1).color(0,0,1).saturate(2).kaleid(50) - .mask(noise(25,2).modulateScale(noise(0.25,0.05))) - .modulateScale(osc(6,-0.5,2).kaleid(50)) - .mult(osc(3,-0.25,2).kaleid(50)) - .scale(0.5,0.5,0.75) - .out() -``` - -### mult - -`.mult( texture, amount )` - -* `texture` - * `color` :: see [color `vec4`](#color-vec4) - * `src` :: see [`src`](#src) - * `shape` :: see [`shape`](#shape) -* `amount` :: float (default `1.0`) - -Multiply images and blend with the texture by `amount`. - -#### Example - -```javascript -osc(9,0.1,2).mult(osc(13,0.5,5)).out() -``` diff --git a/docs/funcs_sources.md b/docs/funcs_sources.md deleted file mode 100644 index 53e964a4..00000000 --- a/docs/funcs_sources.md +++ /dev/null @@ -1,186 +0,0 @@ -## Sources - -Sources are elementary generators that output different types of visual content. - -- [gradient](#gradient) -- [noise](#noise) -- [osc](#osc) -- [out](#out) -- [render](#render) -- [shape](#shape) -- [solid](#solid) -- [src](#src) -- [voronoi](#voronoi) - -### gradient - -`gradient( speed )` - -* `speed` :: float (default `x`) - -#### Example - -```javascript -// gradient sequence at speeds of 1, 2 & 4 -gradient([1,2,4]).out(o0) -``` - -### noise - -`noise( scale, offset )` - -* `scale` :: int (default `10.0`) -* `offset` :: float (default `0.1`) - -Generate [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise). - -#### Example - -```javascript -// noise interpolating between different scales and offsets -noise( ({time}) => Math.sin(time/10)*50 , ({time}) => Math.sin(time/2)/500 ) - .out(o0) -``` - -### osc - -`osc( frequency, sync, offset )` - -* `frequency` :: float (default `60.0`) -* `sync` :: float (default `0.1`) -* `offset` :: float (default `0.0`) - -#### Example - -```javascript -// frequency -osc( [1,10,50,100,250,500].fast(2) ).out(o0) - -// frequency 2 -osc( ({time}) => Math.sin(time/10) * 100 ).out(o0) - -// sync -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o0) - -// offset -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o0) -``` - -### out - -`.out( buffer )` - -* `buffer` - * `osc`: `o0`, `o1`, `o2`, `o3` - * `src`: `s0`, `s1`, `s2`, `s3` - -#### Example - -```javascript -// output four oscillators to different buffers -// and then modulate them together -osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ) // offset - .modulate(o1,0.05) - .modulate(o2,0.05) - .modulate(o3,0.05) - .out(o3) -render(o3) -``` - -### render - -`render( buffer )` - -* `buffer`: buffer (default `o0`) - -#### Example - -```javascript -osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset - -render(o0) // change to o1, o2, or o3 -``` - -```javascript -// see all four buffers at once -osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency -osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2 -osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync -osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset -render() -``` - -### shape - -`shape( sides, radius, smoothing)` - -* `sides` :: int (default `3.0`) -* `radius` :: float (default `0.3`) -* `smoothing` :: float (default `0.01`) - -#### Example - -```javascript -// inverting blurry circle -shape(100,0.01,1).invert(({time})=>Math.sin(time)*2).out(o0) - -// a... rainbow ball? -shape(5,0.5,0.1).repeat(19,19) - .mult(osc(10,1,2)) - .rotate( ({time}) => time%360 ) - .scrollX(1,-0.25) - .mult(shape(15,0.3,0.01) - .rotate( ({time}) => time%360 ) - .scrollX(1,-0.25)) - .out(o0) -``` - -### solid - -`solid( r, g, b, a )` - -* `r` :: float (default `0.0`) -* `g` :: float (default `0.0`) -* `b` :: float (default `0.0`) -* `a` :: float (default `1.0`) - -#### Example - -```javascript -// cycling through red, green and blue -solid([1,0,0],[0,1,0],[0,0,1],1).out(o0) -``` - -### src - -`src( input )` - -* `input` :: input (examples: `o0`, `s1`) - -See `hydra-examples` repository - -### voronoi - -`voronoi( scale, speed, blending )` - -* `scale` :: float (default `5`) -* `speed` :: float (default `0.3`) -* `blending` :: float (default `0.3`) - -Generate [voronoi shapes](https://en.wikipedia.org/wiki/Voronoi_diagram). - -#### Example - -```javascript -// default -voronoi(5,0.3,0.3).out(o0) - -// fireflies -voronoi(25,2,10).color(1,1,0).brightness(0.15).out(o0) -``` diff --git a/docs/funsc_parameter-sequences.md b/docs/funsc_parameter-sequences.md deleted file mode 100644 index 7e531635..00000000 --- a/docs/funsc_parameter-sequences.md +++ /dev/null @@ -1,29 +0,0 @@ -## Parameter sequences - -- [Lists as parameter sequences](#lists-as-parameter-sequences) -- [Functions on parameter sequences](#functions-on-parameter-sequences) - - [fast](#fast) - -### Lists as parameter sequences - -``` -osc( - [80, 100, 200, 50], 1 ) -) -.out(o0) -``` - -### Functions on parameter sequences - -#### fast - -`fast ( amount) ` - -* `amount` :: float (default `x`) - -``` -osc( - [80, 100, 200, 50].fast(0.2), 1 ) -) -.out(o0) -```