Use consistent low_quality threshold in LGraphCanvas (#442)

* Use consistent low_quality threshold in LGraphCanvas

* Add LGraphCanvas.low_quality_zoom_threshold
This commit is contained in:
Chenlei Hu
2025-02-03 12:04:04 -08:00
committed by GitHub
parent 682f4c624f
commit 0ee671843b

View File

@@ -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