viewof preset = {
let makeDict = (pairs) => Object.assign({}, ...Array.from(pairs, ([key, val]) => ({[key]: val}) ));
const params = (keys, vals) => makeDict(keys.map((key, i) => [key, vals[i]]));
const opt = {
slider: (vals) => slider(params(['title','min','max','step','value'], vals)),
color: (vals) => j_color(params(['title','value'], vals)),
};
const options = {
particles: opt.slider( ["Number of Particles", 1, 200, 1, 140 ]),
size: opt.slider( ["Particle Size", .1, 50, .1, 2.5 ]),
jitter: opt.slider( ["Particle Jitter", 0, 1, .1, .3 ]),
inertia: opt.slider( ["Particle Inertia", 0, .2, .01, .01 ]),
minDist: opt.slider( ["Minimum Distance", 0, 200, 1, 50 ]),
distRange: opt.slider( ["Distance Range", 0, 200, 1, 50 ]),
fillAlpha: opt.slider( ["Particle Fill Opacity", 0, 1, .05, .35 ]),
strokeAlpha: opt.slider( ["Particle Stroke Opacity", 0, 1, .05, 1 ]),
ghosting: opt.slider( ["Ghosting", 0, 100, 1, 0 ]),
bgColor: opt.color( ["Background Color", "#1d252e"]),
lineColor: opt.color( ["Line Color", "#9be9ff"]),
fillColor: opt.color( ["Particle Fill Color", "#3d97da"]),
strokeColor: opt.color( ["Particle Stroke Color", "#ffffff"]),
};
const element = html`
<style type="text/css">
.panel {
background-color: #ffffff;
display: grid;
grid-template-columns: auto auto auto auto;
grid-auto-rows: 80px;
padding: 30px;
}
@media only screen and (max-width: 1000px) { .panel { grid-template-columns: auto auto; } }
@media only screen and (max-width: 600px) { .panel { grid-template-columns: auto; } }
</style>
<div class="panel"> ${values(options)} </div>
`;
element.oninput = function() {
const result = {};
for (var x in options) {
result[x] = options[x].value
}
element.value = result;
}
element.oninput();
return element;
function values(dict) {
const result = [];
for (var x in dict) {
result.push(dict[x]);
};
return result;
}
}