Пример #1
0
        def do_replace(item_key, new_image):
            if type(item_key) is not str:
                return new_image

            replace = get_replace(item_key)
            if replace is not None:
                replace = unpack_color_directives(replace)
                new_image = replace_colors(new_image, replace)
            return new_image
Пример #2
0
        def do_replace(item_key, new_image):
            if type(item_key) is not str:
                return new_image

            replace = get_replace(item_key)
            if replace is not None:
                replace = unpack_color_directives(replace)
                new_image = replace_colors(new_image, replace)
            return new_image
Пример #3
0
    def get_hair_image(self, name, hair_type, hair_group, gender, directives):
        # TODO: bbox is from .frame file, need a way to read them still
        species = self.get_species(name.lower())
        image_path = "/humanoid/%s/%s/%s.png" % (name, hair_type, hair_group)

        try:
            image = self.assets.read(image_path, species[0][1], image=True)
            image = Image.open(BytesIO(image)).convert("RGBA").crop((43, 0,
                                                                     86, 43))
            return replace_colors(image, unpack_color_directives(directives))
        except OSError:
            logging.exception("Missing hair image: %s", image_path)
            return
Пример #4
0
    def color_image(self, image, item_data):
        data_keys = item_data.keys()
        new_image = image

        def get_replace(img_str):
            match = re.search("\?replace.+", img_str)
            if match is not None:
                return match.group()
            else:
                return None

        def do_replace(item_key, new_image):
            if type(item_key) is not str:
                return new_image

            replace = get_replace(item_key)
            if replace is not None:
                replace = unpack_color_directives(replace)
                new_image = replace_colors(new_image, replace)
            return new_image

        if "directives" in data_keys:
            replace = unpack_color_directives(item_data["directives"])
            new_image = replace_colors(new_image, replace)
        elif "colorOptions" in data_keys:
            pass
        elif "image" in data_keys:
            new_image = do_replace(item_data["image"], new_image)
        elif "largeImage" in data_keys:
            new_image = do_replace(item_data["largeImage"], new_image)
        elif "inventoryIcon" in data_keys:
            new_image = do_replace(item_data["inventoryIcon"], new_image)
        elif "materialHueShift" in data_keys:
            pass
        elif "drawables" in data_keys:
            pass

        return new_image
Пример #5
0
    def color_image(self, image, item_data):
        data_keys = item_data.keys()
        new_image = image

        def get_replace(img_str):
            match = re.search("\?replace.+", img_str)
            if match is not None:
                return match.group()
            else:
                return None

        def do_replace(item_key, new_image):
            if type(item_key) is not str:
                return new_image

            replace = get_replace(item_key)
            if replace is not None:
                replace = unpack_color_directives(replace)
                new_image = replace_colors(new_image, replace)
            return new_image

        if "directives" in data_keys:
            replace = unpack_color_directives(item_data["directives"])
            new_image = replace_colors(new_image, replace)
        elif "colorOptions" in data_keys:
            pass
        elif "image" in data_keys:
            new_image = do_replace(item_data["image"], new_image)
        elif "largeImage" in data_keys:
            new_image = do_replace(item_data["largeImage"], new_image)
        elif "inventoryIcon" in data_keys:
            new_image = do_replace(item_data["inventoryIcon"], new_image)
        elif "materialHueShift" in data_keys:
            pass
        elif "drawables" in data_keys:
            pass

        return new_image
Пример #6
0
 def grab_sprite(sheet_path, rect, directives):
     sheet = self.assets.read(sheet_path, asset_loc, True)
     img = Image.open(BytesIO(sheet)).convert("RGBA").crop(rect)
     if directives != "":
         img = replace_colors(img, unpack_color_directives(directives))
     return img