utils
import
{
...
}
from
"@motion-canvas/core/lib/utils"
;
General utilities and helper functions.
Classes
-
DetailedError
Interfaces
-
Reference -
ReferenceReceiver
Type Aliases
RefsProperty
Type Parameters
Functions
beginSlide
public
beginSlide
name
:
string
:
ThreadGenerator
Parameters
-
name : string
capitalize
Type Parameters
-
T extends string
Parameters
createRef
Type Parameters
debug
public
debug
payload
:
any
:
void
Logs a debug message with an arbitrary payload.
This method is a shortcut for calling
useLogger().debug()
which allowsyou to more easily log non-string values as well.
Examples
Parameters
-
payload : anyThe payload to log
deprecate
Mark the given function as deprecated.
Type Parameters
Parameters
-
fn : public ()The function to deprecate.
-
message : stringThe log message.
-
remarks ?: stringThe optional log remarks.
endPlayback
public
endPlayback
playback
:
PlaybackStatus
:
void
Parameters
-
playback : PlaybackStatus
endScene
public
endScene
scene
:
Scene
unknown
:
void
Parameters
-
scene : Scene unknown
endThread
public
endThread
thread
:
Thread
:
void
Parameters
-
thread : Thread
errorToLog
public
errorToLog
error
:
any
:
LogPayload
Parameters
-
error : any
finishScene
public
finishScene
():
void
Mark the current scene as ready to transition out.
Usually used together with transitions. When a scene is marked as finished,the transition will start but the scene generator will continue running.
getContext
public
getContext
options
?:
CanvasRenderingContext2DSettings
canvas
:
HTMLCanvasElement
=
...
:
CanvasRenderingContext2D
Parameters
-
options ?: CanvasRenderingContext2DSettings -
canvas : HTMLCanvasElement = ...
isProxyEnabled
public
isProxyEnabled
():
boolean
Check if the proxy is enabled via the plugin by checkingfor
import.meta.env.VITE_MC_PROXY_ENABLED
The value can either be 'true' of 'false'(as strings) if present, or be undefined if not runfrom a vite context or run without the MC Plugin.
makeRef
Type Parameters
Parameters
makeRefs
public
makeRefs
T
extends
public
()
():
RefsProperty
T
Type Parameters
-
T extends public ()
range
public
range
length
:
number
:
number
[]
Create an array containing a range of numbers.
Examples
Parameters
-
length : numberThe length of the array.
startPlayback
public
startPlayback
playback
:
PlaybackStatus
:
void
Parameters
-
playback : PlaybackStatus
startScene
public
startScene
scene
:
Scene
unknown
:
void
Parameters
-
scene : Scene unknown
startThread
public
startThread
thread
:
Thread
:
void
Parameters
-
thread : Thread
useContext
public
useContext
callback
:
public
()
:
public
()
Provide a function to access the Context2D before the scene is rendered.
Parameters
-
callback : public ()The function that will be provided the context before render.
useContextAfter
public
useContextAfter
callback
:
public
()
:
public
()
Provide a function to access the Context2D after the scene is rendered.
Parameters
-
callback : public ()The function that will be provided the context after render.
useDuration
public
useDuration
name
:
string
:
number
Register a time event and get its duration in seconds.
This can be used to better specify when an animation should startas well as how long this animation should take
Examples
Parameters
-
name : stringThe name of the event.
useLogger
public
useLogger
():
Console
Logger
usePlayback
public
usePlayback
():
PlaybackStatus
Get a reference to the playback status.
useRandom
Get the random number generator for the current scene.
useScene
public
useScene
():
Scene
Get a reference to the current scene.
useThread
public
useThread
():
Thread
Get a reference to the current thread.
useTime
public
useTime
():
number
Get the real time since the start of the animation.
The returned value accounts for offsets caused by functions such as
waitFor
.
Examples
viaProxy
public
viaProxy
url
:
string
:
string
Route the given url through a local proxy.
Examples
Parameters
-
url : string