Skip to content

Operators

Daryl Stultz edited this page Jun 2, 2016 · 5 revisions

With Kabuki you chain together "nodes" that carry values from inputs to outputs. Each node can change the value or values coming in to it. You can perform basic math operations, adding together 2 inputs, for example, or map a range of values to another range, even filter or retain values outside a range.

Many operations can be performed on a node. But you need a node to start with. The inputs provided by Kabuki are nodes. You can create nodes from other sources as well.

From an Object

You can create a node from any object that has a value property. If the value changes over time you'll want to use the @property decorator. This is one way to make your own input.

n = kabuki.node_from_object(my_object)

From a Function

You can create a node from any function that returns a value. This is another way to make an input.

n = kabuki.node_from_function(my_function)

From a Literal

Finally, you can create a node from a literal value like so:

n = kabuki.node_from_value(5)

This isn't terribly useful because you can usually pass in a literal in place of a node for some other operation. So you can do this:

n1 = kabuki.node_from_value(5)
n2 = kabuki.node_from_value(3)
n3 = n1.mul(n2)
n3.value # 15

but you'll likely do something like this instead:

n1 = # ... from some input
n2 = # ... from some other operation
n3 = n1.mul(n2)

Next

Clone this wiki locally