Canvas Mode
The canvas mode controls the top-level interaction state of the Kittl canvas, such as when users are actively cropping or erasing an object. You can fetch or update this mode using the SDK.
Getting the Canvas Mode
To check what mode the canvas is currently in:
const result = await kittl.state.getCanvasMode();
if (result.isOk) {
// Mode could be 'erase', 'crop', 'reframe', or `null` (default state)
console.log('Current canvas mode:', result.result);
}
Setting the Canvas Mode
You can also programmatically switch the canvas mode. To reset back to the default state, you can pass null.
// Switch into crop mode
const setModeResult = await kittl.state.setCanvasMode('crop');
if (setModeResult.isOk) {
console.log('Switched to crop mode.');
}