Start serializing UI state

This commit is contained in:
space-nuko
2023-05-04 10:29:44 -05:00
parent fd417c6759
commit 93cf2ed98a
8 changed files with 294 additions and 149 deletions

View File

@@ -3,6 +3,11 @@ import type ComfyApp from "./components/ComfyApp";
import queueState from "./stores/queueState";
import { get } from "svelte/store";
export type SerializedGraphCanvasState = {
offset: Vector2,
scale: number
}
export default class ComfyGraphCanvas extends LGraphCanvas {
app: ComfyApp
@@ -20,6 +25,23 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
this.app = app;
}
serialize(): SerializedGraphCanvasState {
return {
offset: this.ds.offset,
scale: this.ds.scale
}
}
deserialize(data: SerializedGraphCanvasState) {
this.ds.offset = data.offset;
this.ds.scale = data.scale;
}
recenter() {
this.ds.reset();
this.setDirty(true, true)
}
override drawNodeShape(
node: LGraphNode,
ctx: CanvasRenderingContext2D,