Working on documentation

This commit is contained in:
2023-11-17 00:07:01 +01:00
parent 475455c3e3
commit ce943aa1cb
4 changed files with 105 additions and 102 deletions

View File

@ -135,7 +135,7 @@
<details class="" open=true> <details class="" open=true>
<summary class="font-semibold lg:text-xl text-orange-300">Basics</summary> <summary class="font-semibold lg:text-xl text-orange-300">Basics</summary>
<div class="flex flex-col"> <div class="flex flex-col">
<p rel="noopener noreferrer" id="docs_introduction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Introduction </p> <p rel="noopener noreferrer" id="docs_introduction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Welcome </p>
<p rel="noopener noreferrer" id="docs_interface" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interface</p> <p rel="noopener noreferrer" id="docs_interface" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interface</p>
<p rel="noopener noreferrer" id="docs_interaction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interaction</p> <p rel="noopener noreferrer" id="docs_interaction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interaction</p>
<p rel="noopener noreferrer" id="docs_shortcuts" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Keyboard</p> <p rel="noopener noreferrer" id="docs_shortcuts" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Keyboard</p>
@ -167,8 +167,8 @@
<summary class="font-semibold lg:text-xl pb-1 pt-1 text-orange-300">Patterns</summary> <summary class="font-semibold lg:text-xl pb-1 pt-1 text-orange-300">Patterns</summary>
<div class="flex flex-col"> <div class="flex flex-col">
<p rel="noopener noreferrer" id="docs_variables" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Variables</p> <p rel="noopener noreferrer" id="docs_variables" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Global Variables</p>
<p rel="noopener noreferrer" id="docs_lfos" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">LFOs</p> <p rel="noopener noreferrer" id="docs_lfos" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Low Freq Oscs.</p>
<p rel="noopener noreferrer" id="docs_probabilities" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Probabilities</p> <p rel="noopener noreferrer" id="docs_probabilities" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Probabilities</p>
<p rel="noopener noreferrer" id="docs_chaining" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Chaining</p> <p rel="noopener noreferrer" id="docs_chaining" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Chaining</p>
<p rel="noopener noreferrer" id="docs_functions" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Functions</p> <p rel="noopener noreferrer" id="docs_functions" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Functions</p>

View File

@ -16,13 +16,16 @@ You can get the current position of the mouse on the screen by using the followi
- <ic>mouseY()</ic>: the vertical position of the mouse on the screen (as a floating point number). - <ic>mouseY()</ic>: the vertical position of the mouse on the screen (as a floating point number).
${makeExample( ${makeExample(
"FM Synthesizer controlled using the mouse", "Vibrato controlled by mouse",
` `
beat(.25) :: sound('sine') beat(.25) :: sound('sine')
.fmi(mouseX() / 100) .note([0,4,5,10,11,15,16]
.fmh(mouseY() / 100) .palindrome()
.vel(0.2) .scale('pentatonic', 50).beat(.25)
.room(0.9).out() + [-12, 0, 12].beat(0.25))
.vib(mouseX()/700).vibmod(mouseY()/200)
.pan(r(0, 1))
.room(0.35).size(4).out()
`, `,
true true
)} )}
@ -36,15 +39,13 @@ Current mouse position can also be used to generate notes:
${makeExample( ${makeExample(
"The same synthesizer, with note control!", "Using the mouse to output a note!",
` `
beat(.25) :: sound('sine') beat(.25) :: sound('sine')
.fmi(mouseX() / 100) .lpf(7000)
.delay(0.5).delayt(1/6).delayfb(0.2)
.note(noteX()) .note(noteX())
.fmh(mouseY() / 100) .room(0.35).size(4).out()`,
.vel(0.2)
.room(0.9).out()
`,
true true
)} )}

View File

@ -10,24 +10,24 @@ export const patterns = (application: Editor): string => {
It means that the following: It means that the following:
${makeExample( ${makeExample(
"Boring kick", "Boring kick",
` `
beat(1)::sound('kick').out() beat(1)::sound('kick').out()
`, `,
true true
)} )}
can be turned into something more interesting like this easily: can be turned into something more interesting like this easily:
${makeExample( ${makeExample(
"Less boring kick", "Less boring kick",
` `
let c = [1,2].dur(3, 1) let c = [1,2].dur(3, 1)
beat([1, 0.5, 0.25].dur(0.75, 0.25, 1) / c)::sound(['kick', 'fsoftsnare'].beat(0.75)) beat([1, 0.5, 0.25].dur(0.75, 0.25, 1) / c)::sound(['kick', 'fsoftsnare'].beat(0.75))
.ad(0, .25).shape(usine(1/2)*0.5).speed([1, 2, 4].beat(0.5)).out() .ad(0, .25).shape(usine(1/2)*0.5).speed([1, 2, 4].beat(0.5)).out()
`, `,
true true
)} )}
**Topos** comes with a lot of array methods to deal with musical patterns of increasing complexity. Some knowledge of patterns and how to use them will help you to break out of simple loops and repeating structures. The most basic JavaScript data structure is the [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). Topos is extending it with custom methods to describe patterns that evolve over time. These methods can often be chained to compose more complex expressions: <ic>[1, 2, 3].repeatOdd(5).palindrome().beat()</ic>. **Topos** comes with a lot of array methods to deal with musical patterns of increasing complexity. Some knowledge of patterns and how to use them will help you to break out of simple loops and repeating structures. The most basic JavaScript data structure is the [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). Topos is extending it with custom methods to describe patterns that evolve over time. These methods can often be chained to compose more complex expressions: <ic>[1, 2, 3].repeatOdd(5).palindrome().beat()</ic>.
@ -37,18 +37,18 @@ beat([1, 0.5, 0.25].dur(0.75, 0.25, 1) / c)::sound(['kick', 'fsoftsnare'].beat(0
- <ic>beat(division: number)</ic>: this method will return the next value in the list every _n_ pulses. By default, <ic>1</ic> equals to one beat but integer and floating point number values are supported as well. This method is extremely powerful and can be used for many different purposes. Check out the examples. - <ic>beat(division: number)</ic>: this method will return the next value in the list every _n_ pulses. By default, <ic>1</ic> equals to one beat but integer and floating point number values are supported as well. This method is extremely powerful and can be used for many different purposes. Check out the examples.
${makeExample( ${makeExample(
"Light drumming", "Light drumming",
` `
// Every bar, use a different rhythm // Every bar, use a different rhythm
beat([1, 0.75].beat(4)) :: sound('cp').out() beat([1, 0.75].beat(4)) :: sound('cp').out()
beat([0.5, 1].beat(4)) :: sound('kick').out() beat([0.5, 1].beat(4)) :: sound('kick').out()
beat(2)::snd('snare').shape(.5).out() beat(2)::snd('snare').shape(.5).out()
`, `,
true true
)} )}
${makeExample( ${makeExample(
"Using beat to create arpeggios", "Using beat to create arpeggios",
` `
// Arpeggio using pulse divisions // Arpeggio using pulse divisions
beat([.5, .25].beat(0.5)) :: sound('sine') beat([.5, .25].beat(0.5)) :: sound('sine')
.lpf(100+usine(1/4)*400).lpad(2, 0, .25) .lpf(100+usine(1/4)*400).lpad(2, 0, .25)
@ -62,25 +62,25 @@ beat([.5, .25].beat(0.5)) :: sound('sine')
.delayfb(0.5) .delayfb(0.5)
.out() .out()
`, `,
false false
)} )}
${makeExample( ${makeExample(
"Cool ambiance", "Cool ambiance",
` `
beat(.5) :: snd(['kick', 'hat'].beat(0.5)).out() beat(.5) :: snd(['kick', 'hat'].beat(0.5)).out()
beat([2,4].beat(2)) :: snd('shaker').delay(.5).delayfb(.75).delayt(0.125).out() beat([2,4].beat(2)) :: snd('shaker').delay(.5).delayfb(.75).delayt(0.125).out()
flip(2)::beat(1)::snd('froomy').out() flip(2)::beat(1)::snd('froomy').out()
flip(4)::beat(2)::snd('pad').n(2).shape(.5) flip(4)::beat(2)::snd('pad').n(2).shape(.5)
.orbit(2).room(0.9).size(0.9).release(0.5).out() .orbit(2).room(0.9).size(0.9).release(0.5).out()
`, `,
false false
)} )}
- <ic>bar(value: number = 1)</ic>: returns the next value every bar (if <ic>value = 1</ic>). Using a larger value will return the next value every <ic>n</ic> bars. - <ic>bar(value: number = 1)</ic>: returns the next value every bar (if <ic>value = 1</ic>). Using a larger value will return the next value every <ic>n</ic> bars.
${makeExample( ${makeExample(
"A simple drumbeat in no time!", "A simple drumbeat in no time!",
` `
beat(1)::sound(['kick', 'hat', 'snare', 'hat'].beat()).out() beat(1)::sound(['kick', 'hat', 'snare', 'hat'].beat()).out()
beat([1/4, 1/2].dur(1.5, 0.5))::sound(['jvbass', 'fikea'].bar()) beat([1/4, 1/2].dur(1.5, 0.5))::sound(['jvbass', 'fikea'].bar())
.ad(0, .25).room(0.5).size(2).resonance(0.15).lpf( .ad(0, .25).room(0.5).size(2).resonance(0.15).lpf(
@ -88,12 +88,12 @@ beat([1/4, 1/2].dur(1.5, 0.5))::sound(['jvbass', 'fikea'].bar())
* [1, 2].bar()) * [1, 2].bar())
.out() .out()
`, `,
true true
)} )}
${makeExample( ${makeExample(
"Using beat and bar in the same example", "Using beat and bar in the same example",
` `
beat(2)::snd('snare').out() beat(2)::snd('snare').out()
beat([1, 0.5].beat()) :: sound(['bass3'].bar()) beat([1, 0.5].beat()) :: sound(['bass3'].bar())
.freq(100).n([12, 14].bar()) .freq(100).n([12, 14].bar())
@ -102,13 +102,13 @@ beat([1, 0.5].beat()) :: sound(['bass3'].bar())
.speed([1,2,3].beat()) .speed([1,2,3].beat())
.out() .out()
` `
)} )}
- <ic>dur(...list: numbers[])</ic> : keeps the same value for a duration of <ic>n</ic> beats corresponding to the <ic>nth</ic> number of the list you provide. - <ic>dur(...list: numbers[])</ic> : keeps the same value for a duration of <ic>n</ic> beats corresponding to the <ic>nth</ic> number of the list you provide.
${makeExample( ${makeExample(
"Holding a value for n beats", "Holding a value for n beats",
` `
// The second note is kept for twice as long // The second note is kept for twice as long
beat(0.5)::sound('notes').n([1,2].dur(1, 2)) beat(0.5)::sound('notes').n([1,2].dur(1, 2))
.room(0.5).size(8).delay(0.125).delayt(1/8) .room(0.5).size(8).delay(0.125).delayt(1/8)
@ -117,8 +117,8 @@ beat(0.5)::sound('notes').n([1,2].dur(1, 2))
beat(1)::sound(['kick', 'fsnare'].dur(3, 1)) beat(1)::sound(['kick', 'fsnare'].dur(3, 1))
.n([0,3].dur(3, 1)).out() .n([0,3].dur(3, 1)).out()
`, `,
true true
)} )}
## Manipulating notes and scales ## Manipulating notes and scales
@ -126,63 +126,63 @@ beat(1)::sound(['kick', 'fsnare'].dur(3, 1))
- <ic>pitch()</ic>: convert a list of integers to pitch classes - <ic>pitch()</ic>: convert a list of integers to pitch classes
${makeExample( ${makeExample(
"Converting a list of integers to pitch classes using key and scale", "Converting a list of integers to pitch classes using key and scale",
` `
beat(0.25) :: snd('sine') beat(0.25) :: snd('sine')
.pitch([0,1,2,3,4,6,7,8].beat(0.125)) .pitch([0,1,2,3,4,6,7,8].beat(0.125))
.key(["F4","F3"].beat(2.0)) .key(["F4","F3"].beat(2.0))
.scale("minor").out() .scale("minor").ad(0, .25).out()
`, `,
true true
)} )}
- <ic>scale(scale: string, base note: number)</ic>: Map each element of the list to the closest note of the slected scale. [0, 2, 3, 5 ].scale("major", 50) returns [50, 52, <ic>54</ic>, 55]. You can use western scale names like (Major, Minor, Minor pentatonic ...) or [zeitler](https://ianring.com/musictheory/scales/traditions/zeitler) scale names. Alternatively you can also use the integers as used by Ian Ring in his [study of scales](https://ianring.com/musictheory/scales/). - <ic>scale(scale: string, base note: number)</ic>: Map each element of the list to the closest note of the slected scale. [0, 2, 3, 5 ].scale("major", 50) returns [50, 52, <ic>54</ic>, 55]. You can use western scale names like (Major, Minor, Minor pentatonic ...) or [zeitler](https://ianring.com/musictheory/scales/traditions/zeitler) scale names. Alternatively you can also use the integers as used by Ian Ring in his [study of scales](https://ianring.com/musictheory/scales/).
${makeExample( ${makeExample(
"Mapping the note array to the E3 major scale", "Mapping the note array to the E3 major scale",
` `
beat(1) :: snd('gtr') beat(1) :: snd('gtr')
.note([0, 5, 2, 1, 7].scale("Major", 52).beat()) .note([0, 5, 2, 1, 7].scale("Major", 52).beat())
.out() .out()
`, `,
true true
)} )}
- <ic>scaleArp(scale: string, mask: number)</ic>: extrapolate a custom-masked scale from each list elements. [0].scale("major", 3) returns [0,2,4]. <ic>scaleArp</ic> supports the same scales as <ic>scale</ic>. - <ic>scaleArp(scale: string, mask: number)</ic>: extrapolate a custom-masked scale from each list elements. [0].scale("major", 3) returns [0,2,4]. <ic>scaleArp</ic> supports the same scales as <ic>scale</ic>.
${makeExample( ${makeExample(
"Extrapolate a 3-elements Mixolydian scale from 2 notes", "Extrapolate a 3-elements Mixolydian scale from 2 notes",
` `
beat(1) :: snd('gtr') beat(1) :: snd('gtr')
.note([0, 5].scaleArp("mixolydian", 3).beat() + 50) .note([0, 5].scaleArp("mixolydian", 3).beat() + 50)
.out() .out()
`, `,
true true
)} )}
## Iteration using the mouse ## Iteration using the mouse
- <ic>mouseX()</ic> / <ic>mouseY()</ic>: divides the screen in <ic>n</ic> zones and returns the value corresponding to the mouse position on screen.</ic> - <ic>mouseX()</ic> / <ic>mouseY()</ic>: divides the screen in <ic>n</ic> zones and returns the value corresponding to the mouse position on screen.</ic>
${makeExample( ${makeExample(
"Controlling an arpeggio (octave and note) with mouse", "Controlling an arpeggio (octave and note) with mouse",
` `
beat(0.25)::sound('wt_piano') beat(0.25)::sound('wt_piano')
.note([0,2,3,4,5,7,8,9,11,12].scale( .note([0,2,3,4,5,7,8,9,11,12].scale(
'minor', 30 + [0,12,24].mouseY()).mouseX()) 'minor', 30 + [0,12,24].mouseY()).mouseX())
.room(0.5).size(4).lpad(-2, .2).lpf(500, 0.3) .room(0.5).size(4).lpad(-2, .2).lpf(500, 0.3)
.ad(0, .2).out() .ad(0, .2).out()
`, `,
true true
)} )}
## Simple data operations ## Simple data operations
- <ic>palindrome()</ic>: Concatenates a list with the same list in reverse. - <ic>palindrome()</ic>: Concatenates a list with the same list in reverse.
${makeExample( ${makeExample(
"Palindrome filter sweep", "Palindrome filter sweep",
` `
beat([1,.5,.25].beat()) :: snd('wt_stereo') beat([1,.5,.25].beat()) :: snd('wt_stereo')
.speed([1, 0.5, 0.25]) .speed([1, 0.5, 0.25])
.pan(r(0, 1)).freq([100,200,300].beat(0.25)) .pan(r(0, 1)).freq([100,200,300].beat(0.25))
@ -191,15 +191,15 @@ beat([1,.5,.25].beat()) :: snd('wt_stereo')
.lpf([500,1000,2000,4000].palindrome().beat()) .lpf([500,1000,2000,4000].palindrome().beat())
.lpad(4, 0, .25).sustain(0.125).out() .lpad(4, 0, .25).sustain(0.125).out()
`, `,
true true
)} )}
- <ic>random(index: number)</ic>: pick a random element in the given list. - <ic>random(index: number)</ic>: pick a random element in the given list.
- <ic>rand(index: number)</ic>: shorter alias for the same method. - <ic>rand(index: number)</ic>: shorter alias for the same method.
${makeExample( ${makeExample(
"Sipping some gasoline at the robot bar", "Sipping some gasoline at the robot bar",
` `
// rand, random and pick are doing the same thing! // rand, random and pick are doing the same thing!
beat(1)::snd('fhardkick').shape(0.5) beat(1)::snd('fhardkick').shape(0.5)
.ad(0, .1).lpf(500).db(-12).out() .ad(0, .1).lpf(500).db(-12).out()
@ -210,69 +210,69 @@ beat([.5, 1].rand() / 2) :: snd(
.lpf([5000,3000,2000].pick()) .lpf([5000,3000,2000].pick())
.end(0.5).out() .end(0.5).out()
`, `,
true true
)} )}
- <ic>pick()</ic>: pick a random element in the list. - <ic>pick()</ic>: pick a random element in the list.
${makeExample( ${makeExample(
"Picking values in lists", "Picking values in lists",
` `
beat(0.25)::sound(['ftabla', 'fwood'].pick()) beat(0.25)::sound(['ftabla', 'fwood'].pick())
.speed([1,2,3,4].pick()).ad(0, .125).n(ir(1,10)) .speed([1,2,3,4].pick()).ad(0, .125).n(ir(1,10))
.room(0.5).size(1).out() .room(0.5).size(1).out()
`, `,
true true
)} )}
- <ic>degrade(amount: number)</ic>: removes _n_% of the list elements. Lists can be degraded as long as one element remains. The amount of degradation is given as a percentage. - <ic>degrade(amount: number)</ic>: removes _n_% of the list elements. Lists can be degraded as long as one element remains. The amount of degradation is given as a percentage.
${makeExample( ${makeExample(
"Amen break suffering from data loss", "Amen break suffering from data loss",
` `
// Tweak the value to degrade this amen break even more! // Tweak the value to degrade this amen break even more!
beat(.25)::snd('amencutup').n([1,2,3,4,5,6,7,8,9].degrade(20).loop($(1))).out() beat(.25)::snd('amencutup').n([1,2,3,4,5,6,7,8,9].degrade(20).loop($(1))).out()
`, `,
true true
)} )}
- <ic>repeat(amount: number)</ic>: repeat every list elements _n_ times. - <ic>repeat(amount: number)</ic>: repeat every list elements _n_ times.
- <ic>repeatEven(amount: number)</ic>: repeat every pair element of the list _n_ times. - <ic>repeatEven(amount: number)</ic>: repeat every pair element of the list _n_ times.
- <ic>repeatOdd(amount: number)</ic>: repeat every odd element of the list _n_ times. - <ic>repeatOdd(amount: number)</ic>: repeat every odd element of the list _n_ times.
${makeExample( ${makeExample(
"Repeating samples a given number of times", "Repeating samples a given number of times",
` `
beat(.25)::sound('amencutup').n([1,2,3,4,5,6,7,8].repeat(4).beat(.25)).out() beat(.25)::sound('amencutup').n([1,2,3,4,5,6,7,8].repeat(4).beat(.25)).out()
`, `,
true true
)} )}
- <ic>loop(index: number)</ic>: loop takes one argument, the _index_. It allows you to iterate over a list using an iterator such as a counter. This is super useful to control how you are accessing values in a list without relying on a temporal method such as <ic>.beat()</ic> or </ic>.bar()</ic>. - <ic>loop(index: number)</ic>: loop takes one argument, the _index_. It allows you to iterate over a list using an iterator such as a counter. This is super useful to control how you are accessing values in a list without relying on a temporal method such as <ic>.beat()</ic> or </ic>.bar()</ic>.
${makeExample( ${makeExample(
"Don't you know how to count up to 5?", "Don't you know how to count up to 5?",
` `
beat(1) :: sound('numbers').n([1,2,3,4,5].loop($(3, 10, 2))).out() beat(1) :: sound('numbers').n([1,2,3,4,5].loop($(3, 10, 2))).out()
`, `,
true true
)} )}
- <ic>shuffle(): this</ic>: shuffles a list! Simple enough! - <ic>shuffle(): this</ic>: shuffles a list! Simple enough!
${makeExample( ${makeExample(
"Shuffling a list for extra randomness", "Shuffling a list for extra randomness",
` `
beat(1) :: sound('numbers').n([1,2,3,4,5].shuffle().loop($(1)).out() beat(1) :: sound('numbers').n([1,2,3,4,5].shuffle().loop($(1)).out()
`, `,
true true
)} )}
- <ic>rotate(steps: number)</ic>: rotate a list to the right _n_ times. The last value become the first, rinse and repeat. - <ic>rotate(steps: number)</ic>: rotate a list to the right _n_ times. The last value become the first, rinse and repeat.
${makeExample( ${makeExample(
"To make things more complex... here you go", "To make things more complex... here you go",
` `
beat(.25) :: snd('sine').fmi([1.99, 2]) beat(.25) :: snd('sine').fmi([1.99, 2])
.ad(0, .125).lpf(500+r(1,400)) .ad(0, .125).lpf(500+r(1,400))
.lpad(usine()*8, 0, .125) .lpad(usine()*8, 0, .125)
@ -283,21 +283,21 @@ beat(.25) :: snd('sine').fmi([1.99, 2])
.beat(.25)) // while the index changes .beat(.25)) // while the index changes
.out() .out()
`, `,
true true
)} )}
## Filtering ## Filtering
- <ic>unique()</ic>: filter a list to remove repeated values. - <ic>unique()</ic>: filter a list to remove repeated values.
${makeExample( ${makeExample(
"Demonstrative filtering. Final list is [100, 200]", "Demonstrative filtering. Final list is [100, 200]",
` `
// Remove unique and 100 will repeat four times! // Remove unique and 100 will repeat four times!
beat(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out() beat(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out()
`, `,
true true
)} )}
## Simple math operations ## Simple math operations

View File

@ -7,7 +7,9 @@ export const variables = (application: Editor): string => {
# Variables # Variables
By default, each script is independant from each other. Scripts live in their own bubble and you cannot get or set variables affecting a script from any other script. **However**, everybody knows that global variables are cool and should be used everywhere. This is an incredibely powerful tool to use for radically altering a composition in a few lines of code. By default, each script is independant from each other. Scripts live in their own bubble and you cannot get or set variables affecting a script from any other script.
**However**, everybody knows that global variables are cool and should be used everywhere. Global variables are an incredibely powerful tool to radically alter a composition in a few lines of code.
- <ic>variable(a: number | string, b?: any)</ic>: if only one argument is provided, the value of the variable will be returned through its name, denoted by the first argument. If a second argument is used, it will be saved as a global variable under the name of the first argument. - <ic>variable(a: number | string, b?: any)</ic>: if only one argument is provided, the value of the variable will be returned through its name, denoted by the first argument. If a second argument is used, it will be saved as a global variable under the name of the first argument.
- <ic>delete_variable(name: string)</ic>: deletes a global variable from storage. - <ic>delete_variable(name: string)</ic>: deletes a global variable from storage.