Int<->bool conversion

This commit is contained in:
mcDandy
2026-02-02 20:44:20 +01:00
parent d53d725fcc
commit 9d0f87e43f
2 changed files with 53 additions and 2 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ You can also get the node from comfy manager under the name of More math.
## Features
- functions and variables in math expressions
- Conversion between INT and FLOAT; AUDIO and IMAGE (red - real - strenght of cosine of frequency; blue - imaginary - strenght of sine of frequency; green - log1p of amplitude - just so it looks good to humans)
- Conversion between INT and FLOAT; INT and BOOLEAN; AUDIO and IMAGE (red - real - strenght of cosine of frequency; blue - imaginary - strenght of sine of frequency; green - log1p of amplitude - just so it looks good to humans)
- Nodes for FLOAT, CONDITIONING, LATENT, IMAGE, MASK, NOISE, AUDIO, VIDEO, MODEL, CLIP, VAE, SIGMAS and GUIDER
- Vector Math: Support for List literals `[v1, v2, ...]` and operations between lists/scalars/tensors
- Custom functions `funcname(variable,variable,...)->expression;` they can be used in any later defined custom function or in expression. Shadowing inbuilt functions do not work. **Be careful with recursion. There is no stack limit. Got to 700 000 iterations before I got bored.**
+52 -1
View File
@@ -79,6 +79,55 @@ class FloatToIntNode(io.ComfyNode):
def execute(cls, value):
return (int(value),)
class BoolToIntNode(io.ComfyNode):
"""
Converts bool to int.
"""
@classmethod
def define_schema(cls) -> io.Schema:
""" """
return io.Schema(
node_id="mrmth_BoolToInt",
display_name="Bool -> Int",
category="More math",
inputs=[
io.Boolean.Input(id="value", default=0),
],
outputs=[
io.Int.Output(),
],
)
@classmethod
def execute(cls, value):
return (int(value),)
class IntToBoolNode(io.ComfyNode):
"""
Converts int to bool.
"""
@classmethod
def define_schema(cls) -> io.Schema:
""" """
return io.Schema(
node_id="mrmth_IntToBool",
category="More math",
display_name="Int -> bool",
inputs=[
io.Int.Input(id="value", default=0.0),
],
outputs=[
io.Boolean.Output(),
],
)
@classmethod
def execute(cls, value):
return (bool(value),)
class MoreMathExtension(ComfyExtension):
def __init__(self):
@@ -106,6 +155,8 @@ class MoreMathExtension(ComfyExtension):
NoiseMathNodeOLD,
IntToFloatNode,
FloatToIntNode,
BoolToIntNode,
IntToBoolNode,
AudioMathNodeOLD,
VideoMathNode,
VideoMathNodeOLD,
@@ -114,7 +165,7 @@ class MoreMathExtension(ComfyExtension):
SigmasMathNode,
GuiderMathNode,
NoiseMathNode,
AudioMathNode
AudioMathNode,
]