LayerStyle

2167
By chflame
Updated 15 days ago
View on GitHub →See Common Issues →

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

Available Nodes

LayerUtility: NumberCalculatorV2

Documentation for LayerUtility: NumberCalculatorV2 Node

Overview

The LayerUtility: NumberCalculatorV2 node is part of the ComfyUI LayerStyle toolset and is designed for performing arithmetic operations on input numbers. This node is capable of handling operations with both integer and string representations of numbers, making it flexible for a variety of data types in your ComfyUI workflows.

Functionality

The NumberCalculatorV2 node performs mathematical calculations based on the selected operator. It can operate on numerical values provided directly as inputs or those extracted from strings. This capability allows it to process data that may not be strictly numerical at first glance.

Inputs

Required Inputs

  • a_value: A string input that potentially contains a numerical value. The node extracts and uses the first number it finds within the string for calculations. If no number is found, it defaults to 0.

  • b_value: Similar to a_value, this is a string input from which a numerical value is extracted. It defaults to 0 if no number is found.

  • operator: A dropdown selection of arithmetic operations to perform. Options include:

    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
    • Division (/)
    • Exponentiation (**)
    • Floor division (//)
    • Modulus (%)
    • nth_root: Calculates the nth root, where b is the degree of the root.
    • min: Determines the minimum value.
    • max: Determines the maximum value.

Optional Inputs

  • a: An optional direct numerical input that overrides the value extracted from a_value if provided.

  • b: An optional direct numerical input that overrides the value extracted from b_value if provided.

Outputs

  • int: An integer representation of the calculation result. This is useful for cases where an integer result is necessary, such as indices or counting operations.

  • float: A floating-point representation of the result, suitable for more precise calculations or when dealing with non-integer numbers.

  • string: A string representation of the calculated result, useful for debugging or when the result needs to be displayed textually.

Use in ComfyUI Workflows

The LayerUtility: NumberCalculatorV2 node is highly versatile and can be used in any workflow requiring arithmetic operations on dynamic or static numerical inputs. Here are a few examples of its potential uses:

  • Dynamic content generation: Calculations based on user input or data retrieved during the UI process.
  • Conditional logic workflows: Integrating it with nodes like IfExecute or SwitchCaseNode to create complex decision-making processes.
  • Data transformation: Converting strings containing numeric data into usable numbers for further processing or display.

Special Features and Considerations

  • Robust Input Handling: The ability to extract numbers from strings allows for flexible data input, especially when dealing with dynamic text data.

  • Graceful Fallbacks: Defaults to zero if no valid number is extracted from string inputs, preventing errors during execution.

  • Versatility: By providing outputs in integer, float, and string formats, it makes integration into various parts of a workflow seamless.

  • Arithmetic Options: With support for basic and advanced arithmetic operations, this node can be used in a wide range of computational scenarios.

In summary, the NumberCalculatorV2 node is a powerful tool within the ComfyUI environment, enabling complex numerical manipulations and calculations with ease and flexibility.