more docs

This commit is contained in:
jean-emmanuel 2021-12-06 22:01:59 +01:00
parent 2b82b13d05
commit c09f529703
2 changed files with 49 additions and 3 deletions

View file

@ -6,7 +6,22 @@ It has two special properties, `touch` and `draw`, that work like the `script` p
This widget requires a good understanding of the javascript [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) and of the javascript programming language in general.
## `touch`
## Canvas properties
### `valueLength`
This property must be set to the number of values held by the widget : 1 for a simple slider, 2 for an XY pad, etc. Attempts to set the widget's value with a different number of values will be ignored.
### `autoClear`
This is a convenience option that clears the canvas context and calls [`beginPath`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/beginPath) before each drawing. When this property is set to `false`, the canvas must be cleared manually.
### `continuous`
If this property is enabled, the widget will be redrawn at a fixed rate even if not interacted with (see [`draw`](#draw)).
### `touch`
This script is executed when the widget is touched, when it is released, and during the movement of the pointer while the widget is touched.
@ -24,9 +39,9 @@ This script has access to the same variables and functions as the `script` prope
- `altKey`, `ctrlKey`, `shiftKey`: keyboard modifier states
## `draw`
### `draw`
This script is executed when the widget should be redrawn, which is when it's touched and when it receives a value. If the `continuous` property is enabled, the widget will be redrawn at a fixed rate even if not interacted with.
This script is executed when the widget should be redrawn, which is when it's touched and when it receives a value.
This script has access to the same variables and functions as the `script` property (except the event-specific ones), plus the following:

View file

@ -98,6 +98,12 @@
| <h6 id="button_mode">mode<a class="headerlink" href="#button_mode" title="Permanent link">#</a></h6> | `string` | <code>"toggle"</code> | Interraction mode:<br/>- `toggle` (classic on/off switch)<br/>- `push` (press & release)<br/>- `tap` (no release)<br/><br/>Choices: `toggle`, `push`, `tap` |
| <h6 id="button_doubleTap">doubleTap<a class="headerlink" href="#button_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the button require a double tap to be pushed instead of a single tap |
=== "scripting"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="button_script">script<a class="headerlink" href="#button_script" title="Permanent link">#</a></h6> | `script` | <code>""</code> | Script executed whenever the widget's value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.<br/><br/>Additionnal variables:<br/>- `locals.touchCoords`: `[x, y]` array representing the touch coordinates, normalized between 0 and 1. |
??? api "<div id="switch">switch<a class="headerlink" href="#switch" title="Permanent link">#</a></div>"
Value selector button.
@ -732,6 +738,31 @@
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="multixy_script">script<a class="headerlink" href="#multixy_script" title="Permanent link">#</a></h6> | `script` | <code>""</code> | Script executed whenever the widget's value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.<br/><br/>Canvas-based widget have their computed width and height available as local variables:<br/>- `locals.width`<br/>- `locals.height` |
??? api "<div id="canvas">canvas<a class="headerlink" href="#canvas" title="Permanent link">#</a></div>"
Multitouch canvas widget with user-defined drawing functions and touch reactions.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="canvas_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#canvas_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Some style-related properties can be set or read from css using css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--alpha-pips`: `alphaPips`<br/>- `--alpha-pips-text`: `alphaPipsText`<br/><br/>Canvas-based widget have their computed width and height available as css variables (read-only):<br/>- `--widget-width`<br/>- `--widget-height` |
=== "canvas"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="canvas_valueLength">valueLength<a class="headerlink" href="#canvas_valueLength" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the number of values accepted by the widget (minimum 1). Incoming messages that don't comply will be ignored<br/><br/>When calling `set()` from a script, submitted value should be an array only if `valueLength` is greater than 1. |
| <h6 id="canvas_autoClear">autoClear<a class="headerlink" href="#canvas_autoClear" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If set to `false`, the canvas context won't be cleared automatically and `ctx.clear` will need to be called in `draw`. |
| <h6 id="canvas_continuous">continuous<a class="headerlink" href="#canvas_continuous" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | If set to `true`, `draw` will be called at each frame, otherwise it will be called only when the widget is touched and when it receives a value.<br/><br/>Can be a number between 1 and 60 to specify the framerate (default: 30 fps). |
| <h6 id="canvas_touch">touch<a class="headerlink" href="#canvas_touch" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Script executed when the widget is touched. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>. |
| <h6 id="canvas_draw">draw<a class="headerlink" href="#canvas_draw" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Script executed when the widget is redrawn. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>. |
=== "scripting"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="canvas_script">script<a class="headerlink" href="#canvas_script" title="Permanent link">#</a></h6> | `script` | <code>""</code> | Script executed whenever the widget's value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.<br/><br/>Canvas-based widget have their computed width and height available as local variables:<br/>- `locals.width`<br/>- `locals.height` |
## Sliders
??? api "<div id="fader">fader<a class="headerlink" href="#fader" title="Permanent link">#</a></div>"