Skip to content

Commit 576fb19

Browse files
committed
add cli arg
1 parent 083b123 commit 576fb19

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

wgpu_shadertoy/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@
1717
default=(800, 450),
1818
)
1919

20+
argument_parser.add_argument(
21+
"--imgui",
22+
help="automatically turn constants into imgui sliders",
23+
action="store_true",
24+
)
25+
2026

2127
def main_cli():
2228
args = argument_parser.parse_args()
2329
shader_id = args.shader_id
2430
resolution = args.resolution
25-
shader = Shadertoy.from_id(shader_id, resolution=resolution)
31+
imgui = args.imgui
32+
# TODO maybe **args?
33+
shader = Shadertoy.from_id(shader_id, resolution=resolution, imgui=imgui)
2634
shader.show()
2735

2836

wgpu_shadertoy/imgui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def parse_constants(code:str, common_code) -> list[tuple[int, str, int|float, st
2020

2121
# for multipass shader this might need to be per pass (rpass.value) ?
2222
# mataches the macro: #define NAME VALUE
23-
define_pattern = re.compile(r"#define\s+(\w+)\s+(.+)")
23+
define_pattern = re.compile(r"#define\s+(\w+)\s+([\d.]+)")
2424

2525
constants = []
2626
for li, line in enumerate(code.splitlines()):
@@ -119,9 +119,9 @@ def gui(constants, constants_data):
119119
for const in constants:
120120
li, name, value, dtype = const
121121
if dtype == "f":
122-
_, constants_data[name] = ig.slider_float(name, constants_data[name], 0, ((value//10)+1.0)*10.0)
122+
_, constants_data[name] = ig.slider_float(name, constants_data[name], 0, value*2.0)
123123
elif dtype == "I":
124-
_, constants_data[name] = ig.slider_int(name, constants_data[name], 0, ((value//10)+1)*10)
124+
_, constants_data[name] = ig.slider_int(name, constants_data[name], 0, value*2)
125125
# TODO: improve min/max for negatives
126126

127127
ig.end()

0 commit comments

Comments
 (0)