git.s-ol.nu isomorphic-kb-explorer / 1d8dfae
show index-in-pattern s-ol 27 days ago
5 changed file(s) with 39 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
1111 </main>
1212 <aside class="pattern controls">
1313 <div class="control control--preset">
14 <label for="pattern-preset">preset</label>
14 <label for="pattern-preset">pattern</label>
1515 <select id="pattern-preset">
1616 <option value="custom">(custom)</option>
1717 <optgroup label="scales">
2929 <option value="minor-3-">diminished</option>
3030 </optgroup>
3131 </select>
32 </label>
3332 </div>
3433 <div class="control">
35 <label for="pattern-len">(semi)tones</label>
34 <label for="pattern-len">octave size</label>
3635 <input id="pattern-len" type="number" min="4" value="12" />
3736 </div>
3837 <div class="steps">
9998 </svg>
10099 <div class="controls">
101100 <div class="control control--preset">
102 <label for="layout-preset">preset</label>
101 <label for="layout-preset">layout</label>
103102 <select id="layout-preset">
104103 <option value="wicki-hayden">Wicki/Hayden</option>
105104 <option value="janko">Jankó</option>
107106 <option value="gerhard">Gerhard</option>
108107 <option value="custom">(custom)</option>
109108 </select>
110 </label>
111109 </div>
112110 <div class="control control--axis">
113111 <label for="step-1">up</label>
4747 }
4848 });
4949
50 const presetName = Object.keys(PRESETS).find(k => completeState(PRESETS[k]).join(',') === full.join(','));
50 const presetName = Object.keys(PRESETS).find(k => completeState(PRESETS[k]).sort().join(',') === full.sort().join(','));
5151 preset.value = presetName ?? 'custom';
5252
5353 updateFocus();
102102 bg.font = `${size*0.5}px sans-serif`;
103103 bg.textAlign = 'center';
104104 bg.textBaseline = 'middle';
105
106 bg.strokeStyle = '#ff0000';
107 bg.strokeWidth = 5;
108105
109106 const rot = layout.getRot();
110107 const [qq, rr] = layout.getSteps();
123120 const note = q*qq + r*rr;
124121 let step = note % length;
125122 step = (step + length) % length;
123 const oct = Math.floor(note / length);
124 const stepIndex = steps.indexOf(note);
126125
127 if (steps.includes(note)) {
128 bg.fillStyle = '#eeeeee';
129 hexagon(bg);
126 hexagon(bg);
127 if (stepIndex > -1) {
128 bg.fillStyle = '#bae3f5';
130129 bg.fill();
130
131 bg.beginPath();
132 bg.arc(0, 0, size*0.65, 0, Math.PI*2);
131133 }
132
134
135 const c = (1 - Math.abs(oct)/10) * 255;
136 bg.fillStyle = `rgb(${c},${c},${c})`;
137 bg.fill();
138
133139 bg.rotate(-rot);
134140 bg.fillStyle = '#303336';
135 bg.fillText(step, 0, 0);
141 if (stepIndex > -1) {
142 bg.fillText(step, 0, -size*0.3);
143
144 bg.fillStyle = '#505557';
145 bg.fillText(`(${stepIndex})`, 0, size*0.3);
146 } else {
147 bg.fillText(step, 0, 0);
148 }
136149
137150 bg.restore();
138151 }
4444
4545 patternLength.onchange = () => {
4646 length = +patternLength.value;
47 if (!length || length < 4) length = 4;
4748 pattern = pattern.filter(n => n < length);
4849 update();
4950 };
3232 top: 0;
3333 }
3434
35 aside.pattern .steps {
36 display: flex;
37 justify-content: space-between;
38 }
39
40 aside.pattern .steps input {
41 margin: 0.04rem;
42 }
43
44
3545 aside.layout {
3646 bottom: 0;
3747
6575 width: 6rem;
6676 }
6777
68
6978 .control--preset {
7079 padding-bottom: 0.5rem;
7180 border-bottom: 1px solid #b9bdc1;
7685 flex: 1;
7786 }
7887
88 .control--preset label:first-child {
89 font-weight: bold;
90 }
7991
8092 .control--axis label:first-child {
8193 flex: 1;