Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Iconsmoothing: Subtile metrics (🦆 Edition) (#8307)
Browse files Browse the repository at this point in the history
  • Loading branch information
20kdc authored Jun 5, 2022
1 parent a439e4b commit 3d346b3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 33 deletions.
32 changes: 11 additions & 21 deletions Tools/iconsmooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import iconsmooth_lib

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_name = sys.argv[1]
Expand All @@ -35,20 +38,7 @@
out_prefix = sys.argv[4]

# Metric configuration
tile_w = int(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
tile_w, tile_h, subtile_w, subtile_h, remtile_w, remtile_h = iconsmooth_lib.parse_metric_mode(metric_mode)

# Output state configuration
out_states = iconsmooth_lib.conversion_modes[conversion_mode].states
Expand All @@ -67,14 +57,14 @@
tile.paste(src_img, (tx * -tile_w, ty * -tile_h))
# now split that up
# note that THIS is where the weird ordering gets put into place
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_w))
tile_a.paste(tile, (-subtile_w, -subtile_h))
tile_a = PIL.Image.new("RGBA", (remtile_w, remtile_h))
tile_a.paste(tile, (-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.paste(tile, (-subtile_w, 0))
tile_d = PIL.Image.new("RGBA", (subtile_w, remtile_w))
tile_d.paste(tile, (0, -subtile_h))
tile_c.paste(tile, (-subtile_w, 0))
tile_d = PIL.Image.new("RGBA", (subtile_w, remtile_h))
tile_d.paste(tile, ( 0, -subtile_h))
tiles.append([tile_a, tile_b, tile_c, tile_d])

state_size = (tile_w * 2, tile_h * 2)
Expand Down
22 changes: 10 additions & 12 deletions Tools/iconsmooth_inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,24 @@
import sys
import iconsmooth_lib

if len(sys.argv) != 4:
raise Exception("iconsmooth_rt2vxap.py INPREFIX (i.e. Resources/Textures/Structures/catwalk.rsi/catwalk_) <" + iconsmooth_lib.all_conv + "> out.png")

if len(sys.argv) != 5:
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_prefix = sys.argv[1]
conversion_mode = iconsmooth_lib.conversion_modes[sys.argv[2]]
output_name = sys.argv[3]
metric_mode = sys.argv[2]
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
tiles = []

for j in range(8):
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.paste(src_img, (-subtile_w, -subtile_h))
Expand Down
50 changes: 50 additions & 0 deletions Tools/iconsmooth_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,53 @@ def __init__(self, tw, th, 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_"

0 comments on commit 3d346b3

Please sign in to comment.