Iconsmoothing: Subtile metrics (🦆 Edition) (#8307)
This commit is contained in:
@@ -26,7 +26,10 @@ import sys
|
|||||||
import iconsmooth_lib
|
import iconsmooth_lib
|
||||||
|
|
||||||
if len(sys.argv) != 5:
|
if len(sys.argv) != 5:
|
||||||
raise Exception("iconsmooth.py <TEST.png> <TILESIZE> <" + iconsmooth_lib.all_conv + "> <OUTPREFIX>")
|
print("iconsmooth.py in.png METRICS <" + iconsmooth_lib.all_conv + "> OUTPREFIX")
|
||||||
|
print("OUTPREFIX is something like, say, " + iconsmooth_lib.explain_prefix)
|
||||||
|
print(iconsmooth_lib.explain_mm)
|
||||||
|
raise Exception("see printed help")
|
||||||
|
|
||||||
# Input detail configuration
|
# Input detail configuration
|
||||||
input_name = sys.argv[1]
|
input_name = sys.argv[1]
|
||||||
@@ -35,20 +38,7 @@ conversion_mode = sys.argv[3]
|
|||||||
out_prefix = sys.argv[4]
|
out_prefix = sys.argv[4]
|
||||||
|
|
||||||
# Metric configuration
|
# Metric configuration
|
||||||
tile_w = int(metric_mode)
|
tile_w, tile_h, subtile_w, subtile_h, remtile_w, remtile_h = iconsmooth_lib.parse_metric_mode(metric_mode)
|
||||||
tile_h = int(metric_mode)
|
|
||||||
subtile_w = tile_w // 2
|
|
||||||
subtile_h = tile_h // 2
|
|
||||||
|
|
||||||
# Infer remainder from subtile
|
|
||||||
# This is for uneven geometries
|
|
||||||
#
|
|
||||||
# SUB |
|
|
||||||
# ----+----
|
|
||||||
# | REM
|
|
||||||
#
|
|
||||||
remtile_w = tile_w - subtile_w
|
|
||||||
remtile_h = tile_h - subtile_h
|
|
||||||
|
|
||||||
# Output state configuration
|
# Output state configuration
|
||||||
out_states = iconsmooth_lib.conversion_modes[conversion_mode].states
|
out_states = iconsmooth_lib.conversion_modes[conversion_mode].states
|
||||||
@@ -67,14 +57,14 @@ for i in range(48):
|
|||||||
tile.paste(src_img, (tx * -tile_w, ty * -tile_h))
|
tile.paste(src_img, (tx * -tile_w, ty * -tile_h))
|
||||||
# now split that up
|
# now split that up
|
||||||
# note that THIS is where the weird ordering gets put into place
|
# note that THIS is where the weird ordering gets put into place
|
||||||
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_w))
|
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_h))
|
||||||
tile_a.paste(tile, (-subtile_w, -subtile_h))
|
tile_a.paste(tile, (-subtile_w, -subtile_h))
|
||||||
tile_b = PIL.Image.new("RGBA", (subtile_w, subtile_h))
|
tile_b = PIL.Image.new("RGBA", (subtile_w, subtile_h))
|
||||||
tile_b.paste(tile, (0, 0))
|
tile_b.paste(tile, ( 0, 0))
|
||||||
tile_c = PIL.Image.new("RGBA", (remtile_w, subtile_h))
|
tile_c = PIL.Image.new("RGBA", (remtile_w, subtile_h))
|
||||||
tile_c.paste(tile, (-subtile_w, 0))
|
tile_c.paste(tile, (-subtile_w, 0))
|
||||||
tile_d = PIL.Image.new("RGBA", (subtile_w, remtile_w))
|
tile_d = PIL.Image.new("RGBA", (subtile_w, remtile_h))
|
||||||
tile_d.paste(tile, (0, -subtile_h))
|
tile_d.paste(tile, ( 0, -subtile_h))
|
||||||
tiles.append([tile_a, tile_b, tile_c, tile_d])
|
tiles.append([tile_a, tile_b, tile_c, tile_d])
|
||||||
|
|
||||||
state_size = (tile_w * 2, tile_h * 2)
|
state_size = (tile_w * 2, tile_h * 2)
|
||||||
|
|||||||
@@ -25,26 +25,24 @@ import PIL.Image
|
|||||||
import sys
|
import sys
|
||||||
import iconsmooth_lib
|
import iconsmooth_lib
|
||||||
|
|
||||||
if len(sys.argv) != 4:
|
if len(sys.argv) != 5:
|
||||||
raise Exception("iconsmooth_rt2vxap.py INPREFIX (i.e. Resources/Textures/Structures/catwalk.rsi/catwalk_) <" + iconsmooth_lib.all_conv + "> out.png")
|
print("iconsmooth_inv.py INPREFIX METRICS <" + iconsmooth_lib.all_conv + "> out.png")
|
||||||
|
print("INPREFIX is something like, say, " + iconsmooth_lib.explain_prefix)
|
||||||
|
print(iconsmooth_lib.explain_mm)
|
||||||
|
raise Exception("see printed help")
|
||||||
# Input detail configuration
|
# Input detail configuration
|
||||||
input_prefix = sys.argv[1]
|
input_prefix = sys.argv[1]
|
||||||
conversion_mode = iconsmooth_lib.conversion_modes[sys.argv[2]]
|
metric_mode = sys.argv[2]
|
||||||
output_name = sys.argv[3]
|
conversion_mode = iconsmooth_lib.conversion_modes[sys.argv[3]]
|
||||||
|
output_name = sys.argv[4]
|
||||||
|
|
||||||
|
tile_w, tile_h, subtile_w, subtile_h, remtile_w, remtile_h = iconsmooth_lib.parse_metric_mode(metric_mode)
|
||||||
|
|
||||||
# Source loading
|
# Source loading
|
||||||
tiles = []
|
tiles = []
|
||||||
|
|
||||||
for j in range(8):
|
for j in range(8):
|
||||||
src_img = PIL.Image.open(input_prefix + str(j) + ".png")
|
src_img = PIL.Image.open(input_prefix + str(j) + ".png")
|
||||||
# Infer
|
|
||||||
tile_w = src_img.size[0] // 2
|
|
||||||
tile_h = src_img.size[1] // 2
|
|
||||||
subtile_w = tile_w // 2
|
|
||||||
subtile_h = tile_h // 2
|
|
||||||
remtile_w = tile_w - subtile_w
|
|
||||||
remtile_h = tile_h - subtile_h
|
|
||||||
|
|
||||||
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_h))
|
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_h))
|
||||||
tile_a.paste(src_img, (-subtile_w, -subtile_h))
|
tile_a.paste(src_img, (-subtile_w, -subtile_h))
|
||||||
|
|||||||
@@ -115,3 +115,53 @@ conversion_modes = {
|
|||||||
|
|
||||||
all_conv = "tg/citadel/vxa/vxap/rt_states"
|
all_conv = "tg/citadel/vxa/vxap/rt_states"
|
||||||
|
|
||||||
|
def parse_size(sz):
|
||||||
|
if sz.find("x") == -1:
|
||||||
|
szi = int(sz)
|
||||||
|
return szi, szi
|
||||||
|
sp = sz.split("x")
|
||||||
|
return int(sp[0]), int(sp[1])
|
||||||
|
|
||||||
|
def parse_metric_mode_base(mm):
|
||||||
|
if mm.find(".") == -1:
|
||||||
|
# infer point as being in the centre
|
||||||
|
tile_w, tile_h = parse_size(mm)
|
||||||
|
return tile_w, tile_h, tile_w // 2, tile_h // 2
|
||||||
|
sp = mm.split(".")
|
||||||
|
tile_w, tile_h = parse_size(sp[0])
|
||||||
|
subtile_w, subtile_h = parse_size(sp[1])
|
||||||
|
return tile_w, tile_h, subtile_w, subtile_h
|
||||||
|
|
||||||
|
def parse_metric_mode(mm):
|
||||||
|
tile_w, tile_h, subtile_w, subtile_h = parse_metric_mode_base(mm)
|
||||||
|
|
||||||
|
# Infer remainder from subtile
|
||||||
|
# This is for uneven geometries
|
||||||
|
#
|
||||||
|
# SUB |
|
||||||
|
# ----+----
|
||||||
|
# | REM
|
||||||
|
#
|
||||||
|
remtile_w = tile_w - subtile_w
|
||||||
|
remtile_h = tile_h - subtile_h
|
||||||
|
return tile_w, tile_h, subtile_w, subtile_h, remtile_w, remtile_h
|
||||||
|
|
||||||
|
explain_mm = """
|
||||||
|
- Metrics -
|
||||||
|
METRICS is of one of the following forms:
|
||||||
|
TILESIZE
|
||||||
|
TILEWxTILEH
|
||||||
|
TILESIZE.SUBTILEWxSUBTILEH
|
||||||
|
|
||||||
|
These metrics define the tile's size and divide it up as so:
|
||||||
|
|
||||||
|
SUB |
|
||||||
|
----+----
|
||||||
|
| REM
|
||||||
|
|
||||||
|
SUB is either specified as the subtile width/height, or defaults to being half of the tile size.
|
||||||
|
REM is computed from subtracting the subtile size from the tile size.
|
||||||
|
"""
|
||||||
|
|
||||||
|
explain_prefix = "Resources/Textures/Structures/catwalk.rsi/catwalk_"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user