utils
import {...} from "@wangyaoshen/locus-core/lib/utils";
General utilities and helper functions.
Classes
Interfaces
Type Aliases
Variables
DEG2RAD
const DEG2RAD: number = ...
A constant for converting degrees to radians
Examples
RAD2DEG
const RAD2DEG: number = ...
A constant for converting radians to degrees
Examples
Functions
beginSlide
public beginSlidename: string: ThreadGenerator
Parameters
name: string
capitalize
public capitalizevalue: T: CapitalizeT
Parameters
value: T
createRef
public createRef(): ReferenceT
createRefArray
public createRefArray(): ReferenceArrayT
Create an array of references.
The returned object is both an array and a reference that can be passed
directly to the ref property of a node.
Examples
createRefMap
public createRefMap(): ReferenceMapT
Create a group of references.
The returned object lets you easily create multiple references to the same type without initializing them individually.
You can retrieve references by accessing the object's properties. If the reference for a given property does not exist, it will be created automatically.
Examples
debug
public debugpayload: any: void
Logs a debug message with an arbitrary payload.
This method is a shortcut for calling useLogger().debug() which allows
you to more easily log non-string values as well.
Examples
Parameters
payload: anyThe payload to log
deprecate
Mark the given function as deprecated.
Parameters
fn: ...args: TArgs => TReturnThe function to deprecate.
message: stringThe log message.
remarks?: stringThe optional log remarks.
endPlayback
public endPlaybackplayback: PlaybackStatus: void
Parameters
playback: PlaybackStatus
endScene
public endScenescene: Scene: void
Parameters
scene: Scene
endThread
public endThreadthread: Thread: void
Parameters
thread: Thread
errorToLog
public errorToLogerror: any: LogPayload
Parameters
error: any
experimentalLog
Parameters
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 getContextoptions?: CanvasRenderingContext2DSettingscanvas: HTMLCanvasElement = ...: CanvasRenderingContext2D
Parameters
options?: CanvasRenderingContext2DSettingscanvas: HTMLCanvasElement = ...
isProxyEnabled
public isProxyEnabled(): boolean
Check if the proxy is enabled via the plugin by checking
for import.meta.env.VITE_MC_PROXY_ENABLED
The value can either be 'true' of 'false' (as strings) if present, or be undefined if not run from a vite context or run without the MC Plugin.
makeRef
Parameters
makeRefs
public makeRefs(): RefsPropertyT
range
public rangelength: number: number[]
Create an array containing a range of numbers.
Examples
Parameters
length: numberThe length of the array.
startPlayback
public startPlaybackplayback: PlaybackStatus: void
Parameters
playback: PlaybackStatus
startScene
public startScenescene: Scene: void
Parameters
scene: Scene
startThread
public startThreadthread: Thread: void
Parameters
thread: Thread
useContext
public useContextcallback: ctx: CanvasRenderingContext2D => void: () => void
Provide a function to access the Context2D before the scene is rendered.
Parameters
callback: ctx: CanvasRenderingContext2D => voidThe function that will be provided the context before render.
useContextAfter
public useContextAftercallback: ctx: CanvasRenderingContext2D => void: () => void
Provide a function to access the Context2D after the scene is rendered.
Parameters
callback: ctx: CanvasRenderingContext2D => voidThe function that will be provided the context after render.
useDuration
public useDurationname: string: number
Register a time event and get its duration in seconds.
This can be used to better specify when an animation should start as well as how long this animation should take
Examples
Parameters
name: stringThe name of the event.
useLogger
public useLogger(): LoggerConsole
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
flow.waitFor.
Examples
viaProxy
public viaProxyurl: string: string
Route the given url through a local proxy.
Examples
Parameters
url: string