|
10 | 10 | } from '$lib/index.js'; |
11 | 11 |
|
12 | 12 | const basicParam = createFloatParam(createRange('lin', 0, 100)); |
13 | | - const logParam = createFloatParam(createRange('log', 20, 20_000)); |
| 13 | + const freqParam = createFloatParam(createRange('log', 20, 20_000)); |
| 14 | + const gainParam = createFloatParam(createRange('log', -30, 30, Math.E)); |
14 | 15 | const smoothParam = createFloatParam(createRange('lin', 0, 100)); |
15 | 16 | const snapParam = createFloatParam(createRange('lin', 0, 2000)); |
16 | 17 | const enumParam = createEnumParam(['🍍', '🍉', '🍌', '🍎', '🥭', '🍇', '🥝', '🍋'] as const); |
|
20 | 21 | const snapPoints = Array.from({ length: 5 }, (_, i) => i * 500); |
21 | 22 |
|
22 | 23 | let basicValue = 0; |
23 | | - let logValue = 20; |
| 24 | + let freqValue = 20; |
| 25 | + let gainValue = 20; |
24 | 26 | let smoothValue = 0; |
25 | 27 | let snapValue = 0; |
26 | 28 | let enumValue: Variant<typeof enumParam> = '🍎'; |
|
40 | 42 |
|
41 | 43 | <div class="example"> |
42 | 44 | <h2>Logarithmic</h2> |
43 | | - <Knob param={logParam} bind:value={logValue} label="Frequency" unit="hz" /> |
| 45 | + <Knob param={freqParam} bind:value={freqValue} label="Frequency" unit="hz" /> |
| 46 | + <Knob param={gainParam} bind:value={gainValue} label="Gain" unit="dB" /> |
44 | 47 |
|
45 | 48 | <p>A knob with logarithmic scaling (default base is 10).</p> |
46 | 49 | </div> |
|
90 | 93 | <Knob param={oscParam} bind:value={oscValue} label="Oscillator Type" /> |
91 | 94 |
|
92 | 95 | <p> |
93 | | - An example of how <code>EnumParam</code> works. Due to the way TypeScript functions, we need |
94 | | - to use <code>readonly string[]</code> instead of <code>Enum</code>s. |
| 96 | + An example of how <code>EnumParam</code> works: due to the way TypeScript functions, we need |
| 97 | + to use <code>readonly string[]</code> instead of <code>Enum</code>s. Since enums are a small |
| 98 | + subset of some strings, snap markers are added automatically for clarity. |
95 | 99 | </p> |
96 | 100 | <p> |
97 | 101 | Remember to add <code>as const</code> when creating an <code>EnumParam</code> to improve editor |
|
100 | 104 | <p>For instance:</p> |
101 | 105 | <code>const fruitParam = createEnumParam(['🍍', '🍉', '🍌', '🥝', '🍋'] as const);</code> |
102 | 106 | </div> |
| 107 | + |
| 108 | + <div class="example"> |
| 109 | + <h2>Disabled</h2> |
| 110 | + |
| 111 | + <Knob param={basicParam} value={58} disabled /> |
| 112 | + |
| 113 | + <p> |
| 114 | + Just like <code>{'<button>'}</code> and other interactive HTML elements, |
| 115 | + <code>{'<Knob />'}</code> can also be disabled. |
| 116 | + </p> |
| 117 | + </div> |
| 118 | + |
| 119 | + <div class="example"> |
| 120 | + <h2>Colors</h2> |
| 121 | + |
| 122 | + <Knob param={basicParam} value={24} label="Svelte theme" arcColor="#ff3e00" /> |
| 123 | + <Knob |
| 124 | + param={basicParam} |
| 125 | + value={48} |
| 126 | + label="Light theme" |
| 127 | + arcColor="#4292d3" |
| 128 | + bgColor="#eef" |
| 129 | + style="color:#000" |
| 130 | + /> |
| 131 | + <Knob param={basicParam} value={64} label="Disabled color" disabledColor="#aaa" disabled /> |
| 132 | + |
| 133 | + <p> |
| 134 | + Of course, <code>{'<Knob />'}</code> colors can be customized to look however you want. |
| 135 | + <b>Disclaimer</b>: Font and thumb colors are based on the current font color. |
| 136 | + </p> |
| 137 | + </div> |
103 | 138 | </div> |
104 | 139 |
|
105 | 140 | <div class="code"> |
|
0 commit comments