Merge pull request 'set and keep documentation' (#1975) from tyow/localstrudel:composerDocs into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1975
This commit is contained in:
commit
91203233c9
3 changed files with 92 additions and 11 deletions
|
|
@ -1056,7 +1056,55 @@ function _composeOp(a, b, func) {
|
|||
|
||||
// pattern composers
|
||||
const COMPOSERS = {
|
||||
/**
|
||||
* When called on a pattern `a`, with a input pattern `b` (`a.set(b)`),
|
||||
* combines `a` and `b` such that anything defined in `b`
|
||||
* and anything defined in `a` that is *not* defined in `b`
|
||||
* will be in the resulting pattern.
|
||||
*
|
||||
* The structure is maintained from `a`,
|
||||
* because the default pattern alignment is `in`,
|
||||
* see the section on `Pattern Alignment`
|
||||
* in the technical manual in the docs
|
||||
*
|
||||
* This is the inverse of `keep`
|
||||
*
|
||||
* See examples below
|
||||
* @name set
|
||||
* @param {Pattern} pat
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern
|
||||
* @tags internal, combiners
|
||||
* @example
|
||||
* // because input pattern has `s` set,
|
||||
* // it overrides the "sine" declared earlier
|
||||
* note("c a f e").s("sine").set(s("triangle"))
|
||||
*/
|
||||
set: [(a, b) => b],
|
||||
/**
|
||||
* When called on a pattern `a`, with a input pattern `b` (`a.keep(b)`),
|
||||
* combines `a` and `b` such that anything defined in `a`,
|
||||
* and anything defined in `b` that is *not* defined in `a`
|
||||
* will be in the resulting pattern
|
||||
*
|
||||
* The structure is maintained from `a`,
|
||||
* because the default pattern alignment is `in`,
|
||||
* see the section on `Pattern Alignment`
|
||||
* in the technical manual in the docs
|
||||
*
|
||||
* This is the inverse of `set`
|
||||
*
|
||||
* See examples below
|
||||
* @name keep
|
||||
* @param {Pattern} pat
|
||||
* @memberof Pattern
|
||||
* @returns {Pattern}
|
||||
* @tags internal, combiners
|
||||
* @example
|
||||
* // notes, already defined, will stay "c a f e",
|
||||
* // while "s", not defined, will be set to "piano"
|
||||
* note("c a f e").keep(note("e f a c").s("piano"))
|
||||
*/
|
||||
keep: [(a) => a],
|
||||
keepif: [(a, b) => (b ? a : undefined)],
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue