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: SwitchCase

LayerUtility: SwitchCase Node Documentation

Overview

The LayerUtility: SwitchCase node is a part of the ComfyUI LayerStyle utility package. This node allows conditional logic to be integrated into your ComfyUI workflows. It operates similarly to a "switch-case" statement found in many programming languages. Essentially, this node evaluates a switch condition and returns an appropriate output based on matching predefined cases.

Functionality

What This Node Does

The LayerUtility: SwitchCase node compares a specified condition against up to three user-defined cases. Depending on which case matches the condition, the node outputs the corresponding input. If no case matches, it defaults to a predefined fallback output.

Inputs

The node accepts the following inputs:

  1. switch_condition (required): A string which acts as the conditional factor for case matching.

  2. case_1 (required): The first case against which the switch condition is checked.

  3. case_2 (required): The second case for comparison.

  4. case_3 (required): The third available case for evaluation against the switch condition.

  5. input_default (required): The default output if none of the cases match the switch condition.

  6. input_1 (optional): The output associated with case_1 if it matches the switch condition.

  7. input_2 (optional): The output associated with case_2 if it matches the switch condition.

  8. input_3 (optional): The output associated with case_3 if it matches the switch condition.

Outputs

  1. ?: The output of the SwitchCase node is flexible, depending on which input case matches the switch condition. It can result in any type of output specified by the inputs (integer, string, boolean, etc.), as it returns the output associated with the matching case or the default input if no match is found.

Usage in ComfyUI Workflows

The LayerUtility: SwitchCase node serves as an effective tool for introducing logic-based flow control within ComfyUI workflows. Here are some potential use cases:

  • Conditional Data Flow: Direct data downstream based on conditions, such as user inputs or external triggers.

  • Content Customization: Adjust elements in your workflow depending on predefined cases to change settings based on specific inputs.

  • Dynamic Outputs: Use variables or states as conditions to determine which data path or computation to follow.

Special Features or Considerations

  • Flexibility: The node accepts dynamic data input types through optional inputs, making it adaptable to various scenarios in your workflow.

  • Fallback Mechanism: A default case ensures that the node always produces an output, providing robustness to the overall logic flow.

  • Design Simplicity: Its integration is straightforward, reducing complexities in switch-case logic designs.

  • Compatibility Considerations: The node works optimally within workflows that need decision-making capabilities, and it's essential to define cases clearly for effective operation.

Incorporate this node for enhanced control over data routing in your UI workflows, aligning with specific logic criteria.