Add ChairTool for creating individual chairs
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
import { Tool } from '../Tool';
|
||||||
|
import { YjsDocument } from '../../crdt/YjsDocument';
|
||||||
|
|
||||||
|
class ChairTool extends Tool {
|
||||||
|
private width: number = 45; // Default chair width
|
||||||
|
private height: number = 45; // Default chair height
|
||||||
|
|
||||||
|
constructor(yjsDoc: YjsDocument) {
|
||||||
|
super(yjsDoc);
|
||||||
|
this.name = 'ChairTool';
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseDown(event: MouseEvent): void {
|
||||||
|
// Create chair element at click position
|
||||||
|
const x = event.clientX - this.width / 2;
|
||||||
|
const y = event.clientY - this.height / 2;
|
||||||
|
|
||||||
|
this.yjsDoc.createElement({
|
||||||
|
id: Date.now().toString(),
|
||||||
|
type: 'chair',
|
||||||
|
layerId: 'default',
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width: this.width,
|
||||||
|
height: this.height,
|
||||||
|
properties: {
|
||||||
|
// Chair-specific properties can be added here
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseMove(event: MouseEvent): void {
|
||||||
|
// Preview chair at cursor position
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseUp(event: MouseEvent): void {
|
||||||
|
// Handle mouse up if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyUp(event: KeyboardEvent): void {
|
||||||
|
// Handle key up events
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
// Reset any state if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set chair dimensions
|
||||||
|
setDimensions(width: number, height: number): void {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ChairTool };
|
||||||
Reference in New Issue
Block a user