(op: str, *args, clamp=False)
| 298 | |
| 299 | # Helpers to perform math on links and constants. |
| 300 | def node_op(op: str, *args, clamp=False): |
| 301 | node = tree.nodes.new(type="CompositorNodeMath") |
| 302 | node.operation = op |
| 303 | if clamp: |
| 304 | node.use_clamp = True |
| 305 | for i, arg in enumerate(args): |
| 306 | if isinstance(arg, (int, float)): |
| 307 | node.inputs[i].default_value = arg |
| 308 | else: |
| 309 | links.new(arg, node.inputs[i]) |
| 310 | return node.outputs[0] |
| 311 | |
| 312 | def node_clamp(x, maximum=1.0): |
| 313 | return node_op("MINIMUM", x, maximum) |
no outgoing calls
no test coverage detected