From eaec716443dd777756e494d495bbd0e2a04f90fb Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 25 Mar 2020 16:42:09 +0100 Subject: [PATCH] Add random brush node --- Sources/arm/node/NodesBrush.hx | 37 ++++++++++++++++++++++++++++ Sources/arm/node/brush/RandomNode.hx | 15 +++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Sources/arm/node/brush/RandomNode.hx diff --git a/Sources/arm/node/NodesBrush.hx b/Sources/arm/node/NodesBrush.hx index 26cbb07f..f1325ec1 100644 --- a/Sources/arm/node/NodesBrush.hx +++ b/Sources/arm/node/NodesBrush.hx @@ -151,6 +151,43 @@ class NodesBrush { ], buttons: [] }, + { + id: 0, + name: "Random", + type: "RandomNode", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [ + { + id: 0, + node_id: 0, + name: "Min", + type: "VALUE", + color: 0xffa1a1a1, + default_value: 0.0 + }, + { + id: 0, + node_id: 0, + name: "Max", + type: "VALUE", + color: 0xffa1a1a1, + default_value: 1.0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: "Value", + type: "VALUE", + color: 0xffa1a1a1, + default_value: 0.5 + } + ], + buttons: [] + }, { id: 0, name: "Vector", diff --git a/Sources/arm/node/brush/RandomNode.hx b/Sources/arm/node/brush/RandomNode.hx new file mode 100644 index 00000000..6ce656ef --- /dev/null +++ b/Sources/arm/node/brush/RandomNode.hx @@ -0,0 +1,15 @@ +package arm.node.brush; + +@:keep +class RandomNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function get(from: Int): Dynamic { + var min = inputs[0].get(); + var max = inputs[1].get(); + return min + (Math.random() * (max - min)); + } +}