RandomSize, init, and sizes.yaml

This commit is contained in:
JO Jr.
2024-01-27 11:42:10 -05:00
parent 36b77bb8e0
commit 40e4795685
3 changed files with 53 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
from .random_size import RandomSize
LIVE_NODE_CLASS_MAPPINGS = {
"JOJR_RandomSize": RandomSize,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"JOJR_RandomSize": "Random Size",
}
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
+21
View File
@@ -0,0 +1,21 @@
import yaml, os, random
module_root_directory = os.path.dirname(os.path.realpath(__file__))
config_file = os.path.join(module_root_directory,'sizes.yaml')
def read_config(item):
with open(config_file, 'r') as file:
return yaml.safe_load(file)[item]
class RandomSize:
CATEGORY = "quicknodes"
RETURN_TYPES = ("INT","INT")
RETURN_NAMES = ("width","height")
FUNCTION = "func"
def func(self,size:str):
sizes = read_config('sizes')
rand_obj = random.random.Random()
idx = rand_obj.randint(0, len(sizes))
size = sizes[idx]
x, y = [int(v) for v in size.split('x')]
return (x,y)
+22
View File
@@ -0,0 +1,22 @@
sizes:
- 512x512
- 512x768
- 640x768
- 512x1024
- 640x640
- 640x896
- 768x512
- 768x640
- 768x768
- 768x1024
- 1024x512
- 1024x768
- 640x1536
- 768x1344
- 832x1216
- 840x1176
- 896x1152
- 960x1088
- 1024x1024
- 1216x832
- 1344x768