jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.33k stars 602 forks source link

Background turns black when zooming out #468

Open nene opened 1 month ago

nene commented 1 month ago

I would like to keep the background a constant color when zooming in/out.

I discovered various issues about the background color. These suggested setting background_image property. This works, but the image still becomes lighter/darker when zoomed.

Another issue suggested setting the background color of the surrounding div. This only seemed to have a mild effect when zooming in. But not at all when zooming out. Here's an example with the surrounding div background set to red:

https://github.com/jagenjo/litegraph.js/assets/118201/09114c68-6628-4813-a412-aa066fa5d1db

I personally also discovered zoom_modify_alpha property. Setting this to false disables the gradual darkening/lightening. But at one point the background simply flips to black. Here's a demonstration of the following settings:

canvas.background_image = "/grid.png"; // non-transparent image
canvas.zoom_modify_alpha = false;

https://github.com/jagenjo/litegraph.js/assets/118201/0ec0d587-db48-4b35-8b70-62e872d3f0c1

More likely though there's something messed up in the surrounding environment where I'm using litegraph... this project I'm working with is such a mess :(