Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions scripting/api-reference/animation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,39 @@ The duration of the animation.

### `advance`

```lua
advance
```

Advances the animation by the given time in seconds. Returns true if the
animation hasn't reached its end. If the animation is set to loop or ping
pong, it will always return true


### `setTime`

```lua
setTime
```

set the animation time in seconds


### `setTimeFrames`

```lua
setTimeFrames
```

set the animation time in frames


### `setTimePercentage`

```lua
setTimePercentage
```

set the animation time as a percentage of the duration


44 changes: 44 additions & 0 deletions scripting/api-reference/artboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,47 @@ end

### `draw`

```lua
draw
```

Draws the artboard using the provided renderer.


### `advance`

```lua
advance
```

Advances the artboard by the given time in seconds. Returns true if the
artboard should continue receiving advance calls.


### `instance`

```lua
instance
```

Creates a new instance of the artboard with independent state.


### `animation`

```lua
animation
```

Creates an animation instance linked to the artboard instance


### `bounds`

```lua
bounds
```

Returns the bounding box of the artboard as two [Vector](/scripting/api-reference/vector) values: the
minimum point and the maximum point.
```lua
Expand All @@ -76,35 +96,59 @@ print("Bounds height", maxPt.y - minPt.y)

### `node`

```lua
node
```

Returns the node with the given name, or nil if no such node exists.


### `pointerDown`

```lua
pointerDown
```

Pointer event down handler. Each returns a hit-test result, where 0
indicates no hit and non-zero values indicate a hit.


### `pointerUp`

```lua
pointerUp
```

Pointer event up handler. Each returns a hit-test result, where 0
indicates no hit and non-zero values indicate a hit.


### `pointerMove`

```lua
pointerMove
```

Pointer event move handler. Each returns a hit-test result, where 0
indicates no hit and non-zero values indicate a hit.


### `pointerExit`

```lua
pointerExit
```

Pointer event exit handler. Each returns a hit-test result, where 0
indicates no hit and non-zero values indicate a hit.


### `addToPath`

```lua
addToPath
```

Adds the artboard’s geometry to the given path, optionally transformed
by the provided matrix.

Expand Down
32 changes: 32 additions & 0 deletions scripting/api-reference/color.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ title: Color

### `lerp`

```lua
lerp
```

Linearly interpolates between two colors using the parameter t, where
t = 0 returns 'from' and t = 1 returns 'to'.
```lua
Expand All @@ -15,6 +19,10 @@ self.color = Color.lerp(color1, color2, t)

### `rgb`

```lua
rgb
```

Returns a color constructed from red, green, and blue channels. Alpha
defaults to 255 (fully opaque). Channel values are clamped to [0, 255].
```lua
Expand All @@ -25,6 +33,10 @@ self.color = Color.rgb(255, 0, 0)

### `rgba`

```lua
rgba
```

Returns a color constructed from red, green, blue, and alpha channels.
Channel values are clamped to [0, 255].
```lua
Expand All @@ -37,6 +49,10 @@ self.color = Color.rgba(255, 0, 0, 128)

### `red`

```lua
red
```

Returns the red channel of the color. If a value is
provided, returns a new color with that channel updated.
```lua
Expand All @@ -46,6 +62,10 @@ print("Red:", Color.red(myColor))

### `green`

```lua
green
```

Returns the green channel of the color. If a value is
provided, returns a new color with that channel updated.
```lua
Expand All @@ -55,6 +75,10 @@ print("Green:", Color.green(myColor))

### `blue`

```lua
blue
```

Returns the blue channel of the color. If a value is
provided, returns a new color with that channel updated.
```lua
Expand All @@ -64,6 +88,10 @@ print("Blue:", Color.blue(myColor))

### `alpha`

```lua
alpha
```

Returns the alpha channel of the color, or returns a new color with the
alpha channel set to the specified value. Values are clamped to [0, 255].
```lua
Expand All @@ -73,6 +101,10 @@ print("Alpha:", Color.alpha(myColor))

### `opacity`

```lua
opacity
```

Returns the opacity of the color as a normalized value in the range
[0.0, 1.0], or returns a new color with its alpha set from the specified
opacity.
Expand Down
8 changes: 8 additions & 0 deletions scripting/api-reference/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ Provides access to update scheduling for scripted objects.

### `markNeedsUpdate`

```lua
markNeedsUpdate()
```

Provides access to update scheduling for scripted objects.
Marks the object as needing an update on the next frame.


### `viewModel`

```lua
viewModel() -> ViewModel
```

Returns the context view model


16 changes: 16 additions & 0 deletions scripting/api-reference/converter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,40 @@ See [Converter Scripts](/scripting/protocols/converter-scripts).

### `init`

```lua
init
```

Called once when the converter is created. Returns true if initialization
succeeds.


### `convert`

```lua
convert
```

Converts the input value (a view model property) to an output value.
The input parameter must be a DataValue type.


### `reverseConvert`

```lua
reverseConvert
```

Converts the output value back to an input value (a view model property).
The input parameter must be a DataValue type.


### `advance`

```lua
advance
```

Optional per-frame update. Returns true if the converter should continue
receiving advance calls.

Expand Down
32 changes: 32 additions & 0 deletions scripting/api-reference/data-value.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,50 @@ functions for checking the underlying value type.

### `number`

```lua
number
```

Constructors for [DataValue](/scripting/api-reference/data-value) types. Each function returns a mutable
DataValue container of the corresponding underlying type.
Creates a [DataValueNumber](/scripting/api-reference/data-value-number) that stores a number.


### `string`

```lua
string
```

Creates a [DataValueString](/scripting/api-reference/data-value-string) that stores a string.


### `boolean`

```lua
boolean
```

Creates a [DataValueBoolean](/scripting/api-reference/data-value-boolean) that stores a boolean.


### `color`

```lua
color
```

Creates a [DataValueColor](/scripting/api-reference/data-value-color) that stores a [Color](/scripting/api-reference/color).


## Methods

### `isNumber`

```lua
isNumber() -> boolean
```

Base type for values that can be stored in inputs. Provides
functions for checking the underlying value type.
Returns true if the value is a number.
Expand All @@ -45,6 +65,10 @@ print(dv.isNumber) -- true

### `isString`

```lua
isString() -> boolean
```

Returns true if the value is a string.
```lua
local dv: DataValueNumber = DataValue.number()
Expand All @@ -54,6 +78,10 @@ print(dv.isString) -- false

### `isBoolean`

```lua
isBoolean() -> boolean
```

Returns true if the value is a boolean.
```lua
local dv: DataValueNumber = DataValue.number()
Expand All @@ -63,6 +91,10 @@ print(dv.isBoolean) -- false

### `isColor`

```lua
isColor() -> boolean
```

Returns true if the value is a color.
```lua
local dv: DataValueNumber = DataValue.number()
Expand Down
4 changes: 4 additions & 0 deletions scripting/api-reference/enum-values.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: EnumValues

### `__len`

```lua
__len
```

Loading