You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"gui_get_values_code": "def get_values(widgets):\n return {\n 'seed': widgets['seed'].value(),\n 'scale': widgets['scale'].value(),\n 'octaves': widgets['octaves'].value(),\n 'persistence': widgets['persistence'].value(),\n 'lacunarity': widgets['lacunarity'].value()\n }\n\ndef set_initial_state(widgets, state):\n if 'seed' in state: widgets['seed'].setValue(state['seed'])\n if 'scale' in state: widgets['scale'].setValue(state['scale'])\n if 'octaves' in state: widgets['octaves'].setValue(state['octaves'])\n if 'persistence' in state: widgets['persistence'].setValue(state['persistence'])\n if 'lacunarity' in state: widgets['lacunarity'].setValue(state['lacunarity'])",
17
+
"gui_state": {
18
+
"seed": 42,
19
+
"scale": 50.0,
20
+
"octaves": 4,
21
+
"persistence": 0.5,
22
+
"lacunarity": 2.0
23
+
},
24
+
"colors": {
25
+
"title": "#2a2a2a",
26
+
"body": "#141414"
27
+
}
28
+
},
29
+
{
30
+
"uuid": "color-palette",
31
+
"title": "2. Color Palette",
32
+
"pos": [
33
+
411.9682499999998,
34
+
432.89262500000007
35
+
],
36
+
"size": [
37
+
250,
38
+
258
39
+
],
40
+
"code": "@node_entry\ndef get_color_palette(color1: str, color2: str, color3: str) -> str:\n # Pass colors as a delimited string\n return f'{color1};{color2};{color3}'",
41
+
"gui_code": "from PySide6.QtWidgets import QLabel, QPushButton, QColorDialog\nfrom PySide6.QtGui import QColor\n\n# Helper to update button color\ndef update_color(button, color_str):\n button.setStyleSheet(f'background-color: {color_str};')\n\n# --- BUG FIX: Use lambdas to correctly capture scope for signal handlers ---\nlayout.addWidget(QLabel('Gradient Colors:', parent))\n\n# Color 1\nbtn1 = QPushButton('#0D3B66', parent)\nbtn1.clicked.connect(lambda: (lambda b=btn1: (color := QColorDialog.getColor(QColor(b.text()))).isValid() and (b.setText(color.name()), update_color(b, color.name())))())\nupdate_color(btn1, '#0D3B66')\nwidgets['color1_button'] = btn1\nlayout.addWidget(btn1)\n\n# Color 2\nbtn2 = QPushButton('#FAF0CA', parent)\nbtn2.clicked.connect(lambda: (lambda b=btn2: (color := QColorDialog.getColor(QColor(b.text()))).isValid() and (b.setText(color.name()), update_color(b, color.name())))())\nupdate_color(btn2, '#FAF0CA')\nwidgets['color2_button'] = btn2\nlayout.addWidget(btn2)\n\n# Color 3\nbtn3 = QPushButton('#F95738', parent)\nbtn3.clicked.connect(lambda: (lambda b=btn3: (color := QColorDialog.getColor(QColor(b.text()))).isValid() and (b.setText(color.name()), update_color(b, color.name())))())\nupdate_color(btn3, '#F95738')\nwidgets['color3_button'] = btn3\nlayout.addWidget(btn3)",
42
+
"gui_get_values_code": "def get_values(widgets):\n return {\n 'color1': widgets['color1_button'].text(),\n 'color2': widgets['color2_button'].text(),\n 'color3': widgets['color3_button'].text()\n }\n\ndef set_initial_state(widgets, state):\n # Helper to update button color\n def update_color(button, color_str):\n button.setStyleSheet(f'background-color: {color_str};')\n if 'color1' in state: \n widgets['color1_button'].setText(state['color1'])\n update_color(widgets['color1_button'], state['color1'])\n if 'color2' in state: \n widgets['color2_button'].setText(state['color2'])\n update_color(widgets['color2_button'], state['color2'])\n if 'color3' in state: \n widgets['color3_button'].setText(state['color3'])\n update_color(widgets['color3_button'], state['color3'])",
43
+
"gui_state": {
44
+
"color1": "#0D3B66",
45
+
"color2": "#FAF0CA",
46
+
"color3": "#F95738"
47
+
},
48
+
"colors": {
49
+
"title": "#2a2a2a",
50
+
"body": "#141414"
51
+
}
52
+
},
53
+
{
54
+
"uuid": "noise-generator",
55
+
"title": "3. Generate Noise Map",
56
+
"pos": [
57
+
434.79125,
58
+
88.97612500000002
59
+
],
60
+
"size": [
61
+
250,
62
+
192
63
+
],
64
+
"code": "import numpy as np\nimport json\n\n# Helper function for linear interpolation\ndef lerp(a, b, x):\n return a + x * (b - a)\n\n# Perlin noise implementation (for portability)\ndef perlin(x, y, seed=0):\n np.random.seed(seed)\n p = np.arange(256, dtype=int)\n np.random.shuffle(p)\n p = np.stack([p, p]).flatten()\n xi, yi = x.astype(int), y.astype(int)\n xf, yf = x - xi, y - yi\n u, v = xf * xf * xf * (xf * (xf * 6 - 15) + 10), yf * yf * yf * (yf * (yf * 6 - 15) + 10)\n # This is a simplified noise function for demonstration\n n00 = np.sin(xi) + np.cos(yi)\n n10 = np.sin(xi+1) + np.cos(yi)\n n01 = np.sin(xi) + np.cos(yi+1)\n n11 = np.sin(xi+1) + np.cos(yi+1)\n x1 = lerp(n00, n10, u)\n x2 = lerp(n01, n11, u)\n return lerp(x1, x2, v)\n\n@node_entry\ndef generate_noise(seed: int, scale: float, octaves: int, persistence: float, lacunarity: float) -> str:\n width, height = 256, 256\n shape = (width, height)\n \n noise_map = np.zeros(shape)\n frequency = 1\n amplitude = 1\n \n for i in range(octaves):\n lin_x = np.linspace(0, width / scale * frequency, width, endpoint=False)\n lin_y = np.linspace(0, height / scale * frequency, height, endpoint=False)\n x, y = np.meshgrid(lin_x, lin_y)\n noise_map += perlin(x, y, seed + i) * amplitude\n \n amplitude *= persistence\n frequency *= lacunarity\n\n # Normalize to 0-1 range\n if np.max(noise_map) != np.min(noise_map):\n noise_map = (noise_map - np.min(noise_map)) / (np.max(noise_map) - np.min(noise_map))\n \n # Return as a JSON string of a list\n return json.dumps(noise_map.tolist())",
65
+
"gui_code": "",
66
+
"gui_get_values_code": "",
67
+
"gui_state": {},
68
+
"colors": {
69
+
"title": "#006a4e",
70
+
"body": "#004b38"
71
+
}
72
+
},
73
+
{
74
+
"uuid": "colorize-node",
75
+
"title": "4. Colorize Noise Map",
76
+
"pos": [
77
+
751.143125,
78
+
257.22662500000007
79
+
],
80
+
"size": [
81
+
250,
82
+
117
83
+
],
84
+
"code": "import numpy as np\nfrom PIL import Image\nimport json\nimport base64\nimport io\n\n@node_entry\ndef colorize_noise(noise_map_json: str, palette_str: str) -> str:\n try:\n noise_map = np.array(json.loads(noise_map_json))\n colors_hex = palette_str.split(';')\n colors_rgb = [tuple(int(h.lstrip('#')[i:i+2], 16) for i in (0, 2, 4)) for h in colors_hex]\n\n width, height = noise_map.shape\n color_image = np.zeros((height, width, 3), dtype=np.uint8)\n\n # Create a simple linear gradient from the colors\n for i in range(width):\n for j in range(height):\n val = noise_map[i, j]\n if val < 0.5:\n t = val * 2\n color = (int((1-t)*colors_rgb[0][c] + t*colors_rgb[1][c]) for c in range(3))\n else:\n t = (val - 0.5) * 2\n color = (int((1-t)*colors_rgb[1][c] + t*colors_rgb[2][c]) for c in range(3))\n color_image[j, i] = tuple(color)\n\n img = Image.fromarray(color_image, 'RGB')\n \n # Convert image to base64 string to pass to the GUI without saving a file\n buffered = io.BytesIO()\n img.save(buffered, format=\"PNG\")\n img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')\n return img_str\n except Exception as e:\n return f'ERROR: {e}'",
85
+
"gui_code": "",
86
+
"gui_get_values_code": "",
87
+
"gui_state": {},
88
+
"colors": {
89
+
"title": "#5c2a9d",
90
+
"body": "#3c1d63"
91
+
}
92
+
},
93
+
{
94
+
"uuid": "image-preview",
95
+
"title": "5. Texture Preview",
96
+
"pos": [
97
+
1110.0795000000003,
98
+
211.60037500000004
99
+
],
100
+
"size": [
101
+
250,
102
+
348
103
+
],
104
+
"code": "@node_entry\ndef show_image(image_base64: str) -> str:\n # Pass the data through for the GUI logic to use\n return image_base64",
0 commit comments