|
|
|
@ -7,22 +7,7 @@ class Manager { |
|
|
|
|
|
|
|
|
|
playing = false; |
|
|
|
|
|
|
|
|
|
static Size = 20; |
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
p.colorMode(p.HSB, 100); |
|
|
|
|
let count = 100; |
|
|
|
|
for (let i = 0; i < count; i++){ |
|
|
|
|
let rad = i / count / 1e3 + p.PI * 1.05; |
|
|
|
|
let hue = i / count * 100; |
|
|
|
|
let color = p.color(hue, 100, 100); |
|
|
|
|
this.pendula.push( |
|
|
|
|
new Pendulum([1, 1, 1, 1, 1, 1, 1, 1], [50, 50, 50, 50, 50, 50, 50, 100 + i / count / 10000], color) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
p.colorMode(p.RGB); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
static Size = 200; |
|
|
|
|
|
|
|
|
|
init(){ |
|
|
|
|
// @ts-ignore
|
|
|
|
@ -71,7 +56,17 @@ class Manager { |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
add() { |
|
|
|
|
if (this.multiple){ |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
let color = p.color(this.color) |
|
|
|
|
let M = this.masses.slice(0, this.segmentCount); |
|
|
|
|
let L = this.lengths.slice(0, this.segmentCount); |
|
|
|
|
let newPendulum = new Pendulum(M, L, color, this.startAngle); |
|
|
|
|
manager.pendula.push(newPendulum); |
|
|
|
|
} |
|
|
|
|
p.colorMode(p.HSB, 100); |
|
|
|
|
p.colorMode(p.RGB); |
|
|
|
|
}, |
|
|
|
|
deleteAll(){ |
|
|
|
|
if (confirm("Delete all pendulums?")){ |
|
|
|
@ -107,7 +102,7 @@ class Manager { |
|
|
|
|
|
|
|
|
|
update(){ |
|
|
|
|
if (this.playing) { |
|
|
|
|
const h = this.timescale / Math.max(p.frameRate(), 1); |
|
|
|
|
const h = this.timescale / Math.max(p.frameRate(), 30); |
|
|
|
|
this.pendula.forEach(p => p.update(h)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|