Skip to content

Code examples

TenteEEEE edited this page Jul 26, 2019 · 5 revisions

Extension for immoral sign patch

See Ramne's commit.

Details

Dictionary type arguments come from favorite.json.
There is a common argument "add_sign" to enable the patch.
In the init section, we must handle the argument and the sign position like this:

self.sign_position = [844, 666]
try:
    self.add_sign = self.options['add_sign']
except:
    self.add_sign = self.ask(question='Add immoral sign?', default=False)

self.options is the dictionaly argument.
In interactive mode case, there is no dictionary argument, so it causes an error and handles by ask method in the Patcher Class.

After handling the flag, we load and reshape the sign like panties.

if self.add_sign:
    try:
        sign = Image.open(self.options['fsign'])
    except:
        sign = Image.open('./material/anna_sign.png')
    left = ImageOps.mirror(sign)
    margin = 25
    self.sign = Image.new("RGBA", (sign.size[0] * 2 + margin, sign.size[1]))
    self.sign.paste(sign, (sign.size[0] + int(margin/2), 0))
    self.sign.paste(left, (0, 0))

The dictionary argument "fsign" which means the file name of the sign comes from the favorite.json too.
I normally name the reshaped sign texture as self.sign.

Finally, we define a new patch method.

def patch(self, image, transparent=False):
    image = self.convert(image)
    if transparent:
        patched = Image.new("RGBA", self.body_size)
    else:
        patched = self.body.copy()

    if self.add_sign: #added
        self.paste(patched, self.sign, self.sign_position) #added
    patched = self.paste(patched, image, self.pantie_position)
    return patched

Normally it follows the original patcher class.
The differences are just 2 lines which are mentioned above.
The paste method is defined in the patcher class Patcher Class.