From 0ee671843b2c1ea5b4c0729c2409ba4270a9e0a1 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 3 Feb 2025 12:04:04 -0800 Subject: [PATCH] Use consistent low_quality threshold in LGraphCanvas (#442) * Use consistent low_quality threshold in LGraphCanvas * Add LGraphCanvas.low_quality_zoom_threshold --- src/LGraphCanvas.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 3e4fa29f2e..aba52fc064 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -317,6 +317,13 @@ export class LGraphCanvas { LiteGraph.ROUND_RADIUS = value } + /** + * Render low quality when zoomed out. + */ + get low_quality(): boolean { + return this.ds.scale < this.low_quality_zoom_threshold + } + options: { skip_events?: any viewport?: any @@ -376,6 +383,8 @@ export class LGraphCanvas { /** Shape of the markers shown at the midpoint of links. Default: Circle */ linkMarkerShape: LinkMarkerShape = LinkMarkerShape.Circle links_render_mode: number + /** Zoom threshold for low quality rendering. Zoom below this threshold will render low quality. */ + low_quality_zoom_threshold: number = 0.5 /** mouse in canvas coordinates, where 0,0 is the top-left corner of the blue rectangle */ readonly mouse: Point /** mouse in graph coordinates, where 0,0 is the top-left corner of the blue rectangle */ @@ -4781,7 +4790,7 @@ export class LGraphCanvas { const color = node.color || node.constructor.color || LiteGraph.NODE_DEFAULT_COLOR const bgcolor = node.bgcolor || node.constructor.bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR - const low_quality = this.ds.scale < 0.6 // zoomed out + const low_quality = this.low_quality const editor_alpha = this.editor_alpha ctx.globalAlpha = editor_alpha @@ -5162,7 +5171,7 @@ export class LGraphCanvas { ctx.fillStyle = LiteGraph.use_legacy_node_error_indicator ? "#F00" : bgcolor const title_height = LiteGraph.NODE_TITLE_HEIGHT - const low_quality = this.ds.scale < 0.5 + const low_quality = this.low_quality const { collapsed } = node.flags const shape = node._shape || node.constructor.shape || LiteGraph.NODE_DEFAULT_SHAPE