Int<->bool conversion
This commit is contained in:
@@ -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
@@ -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,
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user