import { Tsdraw, type TsdrawCustomTool } from '@tsdraw/react'
import { ToolDefinition, StateNode } from '@tsdraw/core'
class StampIdleState implements StateNode {
readonly id = 'idle'
onPointerDown(info) {
info.context.editor.setDrawStyle({ color: 'violet' })
}
}
const stampTool: TsdrawCustomTool = {
id: 'stamp',
label: 'Stamp',
icon: <span>🔖</span>,
definition: {
id: 'stamp',
initialStateId: 'idle',
stateConstructors: [() => new StampIdleState()],
},
}
function App() {
return <Tsdraw customTools={[stampTool]} />
}