From c09f529703965b213767e489d84da028fcd456c7 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 6 Dec 2021 22:01:59 +0100 Subject: [PATCH] more docs --- resources/docs/docs/widgets/canvas.md | 21 +++++++++++-- .../docs/docs/widgets/properties-reference.md | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/resources/docs/docs/widgets/canvas.md b/resources/docs/docs/widgets/canvas.md index f0c870b1..7241ce32 100644 --- a/resources/docs/docs/widgets/canvas.md +++ b/resources/docs/docs/widgets/canvas.md @@ -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: diff --git a/resources/docs/docs/widgets/properties-reference.md b/resources/docs/docs/widgets/properties-reference.md index 0f8c41b7..ec793638 100644 --- a/resources/docs/docs/widgets/properties-reference.md +++ b/resources/docs/docs/widgets/properties-reference.md @@ -98,6 +98,12 @@ |
mode#
| `string` | "toggle" | Interraction mode:
- `toggle` (classic on/off switch)
- `push` (press & release)
- `tap` (no release)

Choices: `toggle`, `push`, `tap` | |
doubleTap#
| `boolean` | false | Set to `true` to make the button require a double tap to be pushed instead of a single tap | + === "scripting" + + | property | type |default | description | + | --- | --- | --- | --- | + |
script#
| `script` | "" | Script executed whenever the widget's value updates. See documentation.

Additionnal variables:
- `locals.touchCoords`: `[x, y]` array representing the touch coordinates, normalized between 0 and 1. | + ??? api "
switch#
" Value selector button. @@ -732,6 +738,31 @@ | property | type |default | description | | --- | --- | --- | --- | |
script#
| `script` | "" | Script executed whenever the widget's value updates. See documentation.

Canvas-based widget have their computed width and height available as local variables:
- `locals.width`
- `locals.height` | + +??? api "
canvas#
" + Multitouch canvas widget with user-defined drawing functions and touch reactions. + + === "style" + + | property | type |default | description | + | --- | --- | --- | --- | + |
css#
| `string` | "" | CSS rules. See documentation.

Some style-related properties can be set or read from css using css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--alpha-pips`: `alphaPips`
- `--alpha-pips-text`: `alphaPipsText`

Canvas-based widget have their computed width and height available as css variables (read-only):
- `--widget-width`
- `--widget-height` | + + === "canvas" + + | property | type |default | description | + | --- | --- | --- | --- | + |
valueLength#
| `number` | 1 | Defines the number of values accepted by the widget (minimum 1). Incoming messages that don't comply will be ignored

When calling `set()` from a script, submitted value should be an array only if `valueLength` is greater than 1. | + |
autoClear#
| `boolean` | true | If set to `false`, the canvas context won't be cleared automatically and `ctx.clear` will need to be called in `draw`. | + |
continuous#
| `boolean`|
`number` | false | 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.

Can be a number between 1 and 60 to specify the framerate (default: 30 fps). | + |
touch#
| `string` | "" | Script executed when the widget is touched. See documentation. | + |
draw#
| `string` | "" | Script executed when the widget is redrawn. See documentation. | + + === "scripting" + + | property | type |default | description | + | --- | --- | --- | --- | + |
script#
| `script` | "" | Script executed whenever the widget's value updates. See documentation.

Canvas-based widget have their computed width and height available as local variables:
- `locals.width`
- `locals.height` | ## Sliders ??? api "
fader#
"