Skip to content

Commit

Permalink
format code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
zao committed Apr 5, 2024
1 parent 6bdab09 commit 8ffcb36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PyPoE/cli/exporter/wiki/parsers/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,23 @@ def gemshade_constants_from_hex(hex_text: str):
buf = codecs.decode(hex_text.replace(" ", ""), "hex")
return GemShadeConstants(*struct.unpack("<ffff", buf))


def _srgb_to_linear(img):
return np.piecewise(
img,
[img < 0.04045, img >= 0.04045],
[lambda v: v / 12.92, lambda v: ((v + 0.055) / 1.055) ** 2.4],
)


def _linear_to_srgb(img):
return np.piecewise(
img,
[img < 0.0031308, img >= 0.0031308],
[lambda v: v * 12.92, lambda v: 1.055 * v ** (1.0 / 2.4) - 0.055],
)


def _apply_column_map(infobox, column_map: tuple[tuple[str, dict], ...], list_object):
for k, data in column_map:
value = list_object[k]
Expand Down Expand Up @@ -4105,7 +4108,7 @@ def _shade_sigil(self, tex, color):
tex_colour = np.dstack((_srgb_to_linear(samples[:, :, :3]), samples[:, :, 3]))
final = color * tex_colour
final[:, :, :3] = _linear_to_srgb(final[:, :, :3])
return Image.fromarray(np.uint8(final * 255.), 'RGBA')
return Image.fromarray(np.uint8(final * 255.0), "RGBA")

def export_map(self, parsed_args):
r = ExporterResult()
Expand Down

0 comments on commit 8ffcb36

Please sign in to comment.