This commit is contained in:
Bubobubobubobubo
2023-08-28 12:20:27 +00:00
parent d1ebab994a
commit 218032e2fe
2 changed files with 19 additions and 5 deletions

View File

@ -866,6 +866,12 @@ ${t("Demonstrative filtering. Final list is [100, 200]",`
mod(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out() mod(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out()
`,!0)} `,!0)}
- <icode>add()</icode>: add a given amount to every list element.
- <icode>sub()</icode>: add a given amount to every list element.
- <icode>mult()</icode>: add a given amount to every list element.
- <icode>division()</icode>: add a given amount to every list element. The method is named <icode>division</icode> because obviously <icode>div</icode> is already taken.
${t("Simple addition","[1, 2 ,3].add(2).beat()",!0)}
## Simple patterns ## Simple patterns
@ -994,18 +1000,26 @@ The code you enter in any of the scripts is evaluated in strict mode. This tells
There are some techniques that Topos players are using to keep their JavaScript short and tidy. Don't try to write the shortest possible code but use shortcuts when it makes sense. It's sometimes very comforting to take time to write utilities and scripts that you will often reuse. Take a look at the following examples: There are some techniques that Topos players are using to keep their JavaScript short and tidy. Don't try to write the shortest possible code but use shortcuts when it makes sense. It's sometimes very comforting to take time to write utilities and scripts that you will often reuse. Take a look at the following examples:
${t("Shortening your if conditions",`// The && symbol (overriden by :: in Topos) is very often used for conditions! ${t("Shortening your if conditions",`
mod(.75) :: snd('zap').out() // The && symbol (overriden by :: in Topos) is very often used for conditions!
mod(.75) :: snd('linnhats').n([1,4,5].beat()).out()
mod(1) :: snd('bd').out()
//if (true) && log('very true') //if (true) && log('very true')
// These two lines are the same:
// mod(1) && snd('bd').out()
//// mod(1) :: snd('bd').out()
`,!0)} `,!0)}
${t("More complex conditions using ?",`// The ? symbol can be used to write a if/true/false condition ${t("More complex conditions using ?",`
// The ? symbol can be used to write a if/true/false condition
mod(4) ? snd('kick').out() : mod(2)::snd('snare').out() mod(4) ? snd('kick').out() : mod(2)::snd('snare').out()
// (true) ? log('very true') : log('very false') // (true) ? log('very true') : log('very false')
`,!1)} `,!1)}
${t("Using not and other short symbols",`// The ! symbol can be used to reverse a condition ${t("Using not and other short symbols",`
// The ! symbol can be used to reverse a condition
mod(4) ? snd('kick').out() : mod(2)::snd('snare').out() mod(4) ? snd('kick').out() : mod(2)::snd('snare').out()
!mod(2) :: mod(0.5)::snd('clap').out() !mod(2) :: mod(0.5)::snd('clap').out()
`,!1)} `,!1)}

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Topos</title> <title>Topos</title>
<script type="module" crossorigin src="/assets/index-cf946704.js"></script> <script type="module" crossorigin src="/assets/index-281307f5.js"></script>
<link rel="stylesheet" href="/assets/index-da12e15e.css"> <link rel="stylesheet" href="/assets/index-da12e15e.css">
</head> </head>
<style> <style>