From ed62d8df784cdf20319a8a46325f90936480d90a Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Mon, 30 Jun 2025 01:32:20 +0200 Subject: [PATCH] Add documentation for LitegraphService and MaskEditor Introduced two new documentation files: one detailing the main functions and class structure of LitegraphService, and another describing the classes and methods in MaskEditor. These documents provide an overview of available APIs, internal logic, and UI management for developers. --- Doc/LitegraphService | 75 +++++++++++++++++++++++++++++++++++++++++++ Doc/MaskEditor | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 Doc/LitegraphService create mode 100644 Doc/MaskEditor diff --git a/Doc/LitegraphService b/Doc/LitegraphService new file mode 100644 index 0000000..0c2fb5e --- /dev/null +++ b/Doc/LitegraphService @@ -0,0 +1,75 @@ +LitegraphService Documentation + +Main functions of useLitegraphService() + +Node Registration and Creation Functions: + +registerNodeDef(nodeId: string, nodeDefV1: ComfyNodeDefV1) + +- Registers node definition in LiteGraph system +- Creates ComfyNode class with inputs, outputs and widgets +- Adds context menu, background drawing and keyboard handling +- Invokes extensions before registration + +addNodeOnGraph(nodeDef, options) + +- Adds new node to graph at specified position +- By default places node at canvas center + +Navigation and View Functions: + +getCanvasCenter(): Vector2 + +- Returns canvas center coordinates accounting for DPI + +goToNode(nodeId: NodeId) + +- Animates transition to specified node on canvas + +resetView() + +- Resets canvas view to default settings (scale 1, offset [0,0]) + +fitView() + +- Fits canvas view to show all nodes + +Node Handling Functions (internal): + +addNodeContextMenuHandler(node) + +- Adds context menu with options: + + - Open/Copy/Save image (for image nodes) + - Bypass node + - Copy/Paste to Clipspace + - Open in MaskEditor (for image nodes) + +addDrawBackgroundHandler(node) + +- Adds node background drawing logic +- Handles image, animation and video previews +- Manages thumbnail display + +addNodeKeyHandler(node) + +- Adds keyboard handling: + + - Left/Right arrows: navigate between images + - Escape: close image preview + +ComfyNode Class (created by registerNodeDef): + +Main methods: + +- #addInputs() - adds inputs and widgets to node +- #addOutputs() - adds outputs to node +- configure() - configures node from serialized data +- #setupStrokeStyles() - sets border styles (errors, execution, etc.) + +Properties: + +- comfyClass - ComfyUI class name +- nodeData - node definition +- Automatic yellow coloring for API nodes + diff --git a/Doc/MaskEditor b/Doc/MaskEditor new file mode 100644 index 0000000..9bce49b --- /dev/null +++ b/Doc/MaskEditor @@ -0,0 +1,76 @@ +MASKEDITOR.TS FUNCTION DOCUMENTATION + +MaskEditorDialog - Main mask editor class + +- getInstance() - Singleton pattern, returns editor instance +- show() - Opens the mask editor +- save() - Saves mask to server +- destroy() - Closes and cleans up editor +- isOpened() - Checks if editor is open + +CanvasHistory - Change history management + +- saveState() - Saves current canvas state +- undo() - Undo last operation +- redo() - Redo undone operation +- clearStates() - Clears history + +BrushTool - Brush tool + +- setBrushSize(size) - Sets brush size +- setBrushOpacity(opacity) - Sets brush opacity +- setBrushHardness(hardness) - Sets brush hardness +- setBrushType(type) - Sets brush shape (circle/square) +- startDrawing() - Starts drawing +- handleDrawing() - Handles drawing during movement +- drawEnd() - Ends drawing + +PaintBucketTool - Fill tool + +- floodFill(point) - Fills area with color from point +- setTolerance(tolerance) - Sets color tolerance +- setFillOpacity(opacity) - Sets fill opacity +- invertMask() - Inverts mask + +ColorSelectTool - Color selection tool + +- fillColorSelection(point) - Selects similar colors +- setTolerance(tolerance) - Sets selection tolerance +- setLivePreview(enabled) - Enables/disables live preview +- setComparisonMethod(method) - Sets color comparison method +- setApplyWholeImage(enabled) - Applies to whole image +- setSelectOpacity(opacity) - Sets selection opacity + +UIManager - Interface management + +- updateBrushPreview() - Updates brush preview +- setBrushVisibility(visible) - Shows/hides brush +- screenToCanvas(coords) - Converts screen coordinates to canvas +- getMaskColor() - Returns mask color +- setSaveButtonEnabled(enabled) - Enables/disables save button + +ToolManager - Tool management + +- setTool(tool) - Sets active tool +- getCurrentTool() - Returns active tool +- handlePointerDown/Move/Up() - Handles mouse/touch events + +PanAndZoomManager - View management + +- zoom(event) - Zooms in/out canvas +- handlePanStart/Move() - Handles canvas panning +- initializeCanvasPanZoom() - Initializes canvas view +- smoothResetView() - Smoothly resets view + +MessageBroker - Communication system + +- publish(topic, data) - Publishes message +- subscribe(topic, callback) - Subscribes to topic +- pull(topic, data) - Pulls data from topic +- createPullTopic/PushTopic() - Creates communication topics + +KeyboardManager - Keyboard handling + +- addListeners() - Adds keyboard listeners +- removeListeners() - Removes listeners +- isKeyDown(key) - Checks if key is pressed