This is a prototype for generating interactive panels starting from vector drawings of (real) synth. It will be used in the [mod cms](https://pad.xpub.nl/p/modcms), a CMS for storing patch of analog synthetizer in a workbook fashion. In the future maybe also making sounds out of it? Who knows.
ATM the interactive widgets are: knobs and sockets. For the knob we are using the [input-knobs.js](https://g200kg.github.io/input-knobs/) library. It's a small library that turns `<input>` HTML elements into controller of different types (knobs, fader, switch, etc)
The sockets are modelled on the modular idea of connecting things with cables. To see more look at [spaghetti](https://git.xpub.nl/kamo/spaghetti).
The idea of using SVG is borrowed from VCV rack, in this way the synth could be created starting from a drawing.
In the SVG there are two different layers: one is for the design and the other for the parameters. With a precise convention on colors and names in the second, the Panel class can mount the interactive knobs and sockets on the synth.
### Key:
<spanstyle='color: red'>`#FF0000` Red</span> elements in the SVG `params` layer will be turned into knobs. Their ID will be the linked parameter. So for instance an `<ellipse id='LFO' />` Will generate a Knob controlling the value of LFO rate
<spanstyle='color: #00FF00'>`#00FF00` Green</span> elements in the SVG `params` layer will be turned into sockets. Their ID will be the name of the socket.
This will create a panel with a knob labeled `sun` and two sockets `morning` and `night`. Of course you don't have to write the SVG line by line: this is just a standard export from your favourite vector graphics editor (like Inkscape, Figma, Illustrator, etc)
The only important thing to make the script works is to export every element with its ID (usually the name of the layer or the element in the vector graphics software) and to group all the params in a group named `params`.
# How to use it
- Create an HTML page
- Load the panel.js script in the `<head>`
- Load your script
- Instantiate a new Panel passing your SVG and an HTML container