mirror of
https://github.com/altoiddealer/--sd-webui-ar-plusplus.git
synced 2026-01-26 19:19:55 +00:00
Updated to convenient settings
Make calculation of height and width inverse, that is, the way it is convenient for me Disable `calculator_button` in css Use flex(dynamic) width for all buttons Add resolution presets by formula: `f(x) = 512 + (1024-512)/4*x, 0 <= x <= 4 ` Add ratios presets
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
**/*.swp
|
||||
**/.mypy_cache
|
||||
**/.mypy_cache
|
||||
*.py[cod]
|
||||
aspect_ratios.txt
|
||||
resolutions.txt
|
||||
|
||||
@@ -34,12 +34,12 @@ class ARButton(ToolButton):
|
||||
|
||||
def apply(self, w, h):
|
||||
if self.ar > 1.0: # fix height, change width
|
||||
w = self.ar * h
|
||||
elif self.ar < 1.0: # fix width, change height
|
||||
h = w / self.ar
|
||||
else: # set minimum dimension to both
|
||||
min_dim = min([w, h])
|
||||
w, h = min_dim, min_dim
|
||||
elif self.ar < 1.0: # fix width, change height
|
||||
w = h * self.ar
|
||||
else:
|
||||
new_value = max([w, h])
|
||||
w, h = new_value, new_value
|
||||
|
||||
return list(map(round, [w, h]))
|
||||
|
||||
@@ -110,10 +110,11 @@ def parse_resolutions_file(filename):
|
||||
# TODO: write a generic function handling both cases
|
||||
def write_aspect_ratios_file(filename):
|
||||
aspect_ratios = [
|
||||
"1:1, 1.0 # 1:1 ratio based on minimum dimension\n",
|
||||
"3:2, 3/2 # Set width based on 3:2 ratio to height\n",
|
||||
"4:3, 4/3 # Set width based on 4:3 ratio to height\n",
|
||||
"16:9, 16/9 # Set width based on 16:9 ratio to height",
|
||||
"1:1, 1.0\n",
|
||||
"3:2, 3/2\n",
|
||||
"4:3, 4/3\n",
|
||||
"16:9, 16/9\n",
|
||||
"21:9, 21/9\n",
|
||||
]
|
||||
with open(filename, "w", encoding="utf-8") as f:
|
||||
f.writelines(aspect_ratios)
|
||||
@@ -121,9 +122,11 @@ def write_aspect_ratios_file(filename):
|
||||
|
||||
def write_resolutions_file(filename):
|
||||
resolutions = [
|
||||
"1, 512, 512 # 1:1 square\n",
|
||||
"2, 768, 512 # 3:2 landscape\n",
|
||||
"3, 403, 716 # 9:16 portrait",
|
||||
"512, 512, 512\n",
|
||||
"640, 640, 640\n",
|
||||
"768, 768, 768\n",
|
||||
"896, 896, 896\n",
|
||||
"1024, 1024, 1024",
|
||||
]
|
||||
with open(filename, "w", encoding="utf-8") as f:
|
||||
f.writelines(resolutions)
|
||||
|
||||
16
style.css
16
style.css
@@ -1,19 +1,17 @@
|
||||
#txt2img_row_aspect_ratio button,
|
||||
#img2img_row_aspect_ratio button {
|
||||
min-width: 2.5em !important;
|
||||
max-width: fit-content !important;
|
||||
margin: 0 0 0.25em 0 !important;
|
||||
#txt2img_container_aspect_ratio {
|
||||
gap: 5px !important;
|
||||
}
|
||||
|
||||
#txt2img_row_aspect_ratio button,
|
||||
#img2img_row_aspect_ratio button,
|
||||
#txt2img_row_resolutions button,
|
||||
#img2img_row_resolutions button {
|
||||
min-width: 2.5em !important;
|
||||
max-width: fit-content !important;
|
||||
margin: 0 0 0.25em 0 !important;
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
/* Fix size and display of show/hide calculator buttons */
|
||||
button#arc_show_calculator_button {
|
||||
display: none;
|
||||
padding: 0 .75em;
|
||||
background-color: #ffffff;
|
||||
--tw-gradient-from: #ffffff;
|
||||
@@ -21,4 +19,4 @@ button#arc_show_calculator_button {
|
||||
}
|
||||
button#arc_hide_calculator_button {
|
||||
padding: 0 .75em;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user