Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CR_ListProduct node #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions node_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"CR Repeater": CR_Repeater,
"CR XY Product": CR_XYProduct,
"CR Text List To String": CR_TextListToString,
"CR List Product": CR_ListProduct,
### Aspect Ratio Nodes
"CR SD1.5 Aspect Ratio": CR_AspectRatioSD15,
"CR SDXL Aspect Ratio": CR_SDXLAspectRatio,
Expand Down Expand Up @@ -323,6 +324,7 @@
"CR Repeater": "🛠️ CR Repeater",
"CR XY Product": "🛠️ CR XY Product",
"CR Text List To String": "🛠️ CR Text List To String",
"CR List Product": "🛠️ CR List Product",
### Aspect Ratio Nodes
"CR SD1.5 Aspect Ratio": "🔳 CR SD1.5 Aspect Ratio",
"CR SDXL Aspect Ratio": "🔳 CR SDXL Aspect Ratio",
Expand Down
7 changes: 4 additions & 3 deletions nodes/nodes_graphics_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy as np
import torch
import glob
import os
import platform
from PIL import Image, ImageDraw, ImageOps, ImageFont
Expand Down Expand Up @@ -460,12 +461,12 @@ def INPUT_TYPES(cls):
font_dir = os.path.join(system_root, "Fonts") if system_root else None
# Default debian-based Linux & MacOS font dirs
elif platform.system() == "Linux":
font_dir = "/usr/share/fonts/truetype"
font_dir = "/usr/share/fonts"
elif platform.system() == "Darwin":
font_dir = "/System/Library/Fonts"

file_list = [f for f in os.listdir(font_dir) if os.path.isfile(os.path.join(font_dir, f)) and f.lower().endswith(".ttf")]
file_list = glob.glob(os.path.join(font_dir, "**", "*.ttf"))

return {"required": {
"font_name": (file_list,),
}
Expand Down
23 changes: 23 additions & 0 deletions nodes/nodes_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def INPUT_TYPES(s):
return {"required": {"multiline_text": ("STRING", {"multiline": True, "default": "text"}),
"start_index": ("INT", {"default": 0, "min": 0, "max": 9999}),
"max_rows": ("INT", {"default": 1000, "min": 1, "max": 9999}),
"loops": ("INT", {"default": 1, "min": 1, "max": 999}),
}
}

Expand Down Expand Up @@ -832,6 +833,27 @@ def cycle(self, values, repeats, loops=1):

return (float_list_out, int_list_out, show_help, )

class CR_ListProduct:

@classmethod
def INPUT_TYPES(s):
return {"required": {
"x": (any_type, ),
"y": (any_type, ),
}
}

INPUT_IS_LIST = (True, True,)
RETURN_TYPES = (any_type, any_type, "INT")
RETURN_NAMES = ("out x", "out y", "Span")
OUTPUT_IS_LIST = (True, True, False)
FUNCTION = "cycle"
CATEGORY = icons.get("Comfyroll/List")

def cycle(self, x, y):
y_values, x_values = zip(*product(y, x))
return list(x_values), list(y_values), len(x)

#---------------------------------------------------------------------------------------------------------------------#
# MAPPINGS
#---------------------------------------------------------------------------------------------------------------------#
Expand All @@ -856,6 +878,7 @@ def cycle(self, values, repeats, loops=1):
"CR Batch Images From List": CR_MakeBatchFromImageList,
"CR Intertwine Lists" : CR_IntertwineLists,
"CR Repeater": CR_Repeater,
"CR List Product": CR_ListProduct,
"CR XY Product": CR_XYProduct,
"CR Text List To String": CR_TextListToString,
}
Expand Down