LNXSDK/leenkx/Sources/leenkx/logicnode/CanvasGetScaleNode.hx
2025-01-22 16:18:30 +01:00

37 lines
665 B
Haxe

package leenkx.logicnode;
import iron.Scene;
import leenkx.trait.internal.CanvasScript;
class CanvasGetScaleNode extends LogicNode {
var width: Int;
var height: Int;
public function new(tree: LogicTree) {
super(tree);
}
#if lnx_ui
override function run(from: Int) {
var element = inputs[1].get();
var canvas = CanvasScript.getActiveCanvas();
canvas.notifyOnReady(() -> {
var e = canvas.getElement(element);
if (e == null) return;
height = e.height;
width = e.width;
runOutput(0);
});
}
override function get(from: Int): Dynamic {
if (from == 1) return height;
else if (from == 2) return width;
else return 0;
}
#end
}