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

Getting the coordinates on a graph #470

Open EmmaShredda opened 3 weeks ago

EmmaShredda commented 3 weeks ago

I'm really banging my head against the wall here. I can't for the life of me figure out how to get the graph coordinates from any other .js file. Like I simply want to add a node at the center of my screen, no matter where I am in the graph, but everything I try just keeps adding the node to 0,0.

daniel-lewis-ab commented 16 hours ago

In case you haven't got it yet.

LGraphNode.prototype.pos is a Float32[] where you have x, y from the top left of the barely visible blue box (0,0). The provided number needs to be a valid number (not suffixed with 'px') as per HTMLCanvas.