Export Symbols
This commit is contained in:
parent
c44be9ec68
commit
6facbd4c93
BIN
imgs/tutorial.png
Normal file
BIN
imgs/tutorial.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
8
main.js
8
main.js
@ -1,5 +1,9 @@
|
|||||||
import { Resistor, SeriesResistor, ParallelResistor } from './modules/resistors.js';
|
import { Resistor, SeriesResistor, ParallelResistor } from './modules/resistors.js';
|
||||||
|
|
||||||
|
window.Resistor = Resistor
|
||||||
|
window.SeriesResistor = SeriesResistor
|
||||||
|
window.ParallelResistor = ParallelResistor
|
||||||
|
|
||||||
var resistorValues = [100, 1000]
|
var resistorValues = [100, 1000]
|
||||||
var N = 4
|
var N = 4
|
||||||
var maxValue = Math.max(...resistorValues)
|
var maxValue = Math.max(...resistorValues)
|
||||||
@ -41,6 +45,7 @@ console.log(`Parameters: N = ${N}, values = ${resistorValues} `);
|
|||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
bottomUpDP();
|
bottomUpDP();
|
||||||
console.log("Finished computation of DP array");
|
console.log("Finished computation of DP array");
|
||||||
|
window.numberline = numberline
|
||||||
|
|
||||||
function missings() {
|
function missings() {
|
||||||
var missing = new Set()
|
var missing = new Set()
|
||||||
@ -52,6 +57,3 @@ function missings() {
|
|||||||
}
|
}
|
||||||
console.log(`We found a composite resistor for every value in the range [1, ${N * maxValue + 1}] but for: ${[...missings()].join(",")}`)
|
console.log(`We found a composite resistor for every value in the range [1, ${N * maxValue + 1}] but for: ${[...missings()].join(",")}`)
|
||||||
|
|
||||||
numberline[420].draw() // Draw the Resistor diagram for 420 Ohm as SVG
|
|
||||||
|
|
||||||
console.log(numberline)
|
|
||||||
|
@ -35,7 +35,7 @@ class Resistor {
|
|||||||
var [width, height] = [50, 100]
|
var [width, height] = [50, 100]
|
||||||
return [svg, width, height]
|
return [svg, width, height]
|
||||||
}
|
}
|
||||||
draw() {
|
draw(element = document.getElementsByTagName("body")[0]) {
|
||||||
var [svg, width, height] = this.getSVG();
|
var [svg, width, height] = this.getSVG();
|
||||||
var maxHeight = height + 2*25
|
var maxHeight = height + 2*25
|
||||||
var maxWidth = width
|
var maxWidth = width
|
||||||
@ -47,7 +47,7 @@ class Resistor {
|
|||||||
${svg}
|
${svg}
|
||||||
</g>
|
</g>
|
||||||
</svg>`
|
</svg>`
|
||||||
document.getElementsByTagName("body")[0].innerHTML = thesvg;
|
element.innerHTML += thesvg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user