2022-05-16 23:48:22 +00:00
|
|
|
init python:
|
|
|
|
whitespace_dict = {}
|
2022-09-21 18:22:14 +00:00
|
|
|
with renpy.open_file("images.whitespace") as fp:
|
2022-05-16 23:48:22 +00:00
|
|
|
line = fp.readline()
|
|
|
|
while line:
|
|
|
|
path, area = line.strip("\r\n").split(':')
|
2022-09-21 20:57:04 +00:00
|
|
|
whitespace_dict[path] = list(map(int, area.split(',')))
|
2022-05-16 23:48:22 +00:00
|
|
|
line = fp.readline()
|
|
|
|
|
|
|
|
def crop_whitespace(path):
|
|
|
|
# Return box from whitespace_dict, or calculate and store it
|
|
|
|
if path in whitespace_dict:
|
|
|
|
box = whitespace_dict[path]
|
|
|
|
else:
|
IO Overhaul, Refactoring, and more
* Refactored DollFace
* Refactored DollBody
* Refactored DollCum
* Refactored DollCloth
* Refactored Doll
* Refactored clothing item zorders
* Refactored implementation of body, face, cum, clothing layers
* Refactored function calls
* Removed DollLipstick
* Added DollMakeup class, allowing adding dynamic clothes tracking face states
* Added DollClothDynamic, allowing dynamic clothes tracking other cloth states with bangs support
* Added cache to frequently called functions, drastically reducing the overhead
* Added hash system, reducing clone redundancy
* Added layer modifiers support for all types (face, body, cum, clothes etc.)
* Added support for an arbitrary number of equipped multislot clothing items (makeup, tattoos, piercings, etc.)
* Simplified initialization for clothing items and dolls
* Simplified class function calls
* Reduced the number of image creation calls
* Added hue support for additional skin layers
* Added displayable support to image cropping function
* Replaced store cache with built-in functools cache for _list_files function
* Refactored all character files
* and more...
2023-01-14 23:04:54 +00:00
|
|
|
if isinstance(path, str):
|
|
|
|
surf = Image(path).load()
|
|
|
|
elif isinstance(path, im.Image):
|
|
|
|
surf = path.load()
|
|
|
|
elif isinstance(path, Transform):
|
|
|
|
surf = path.child.load()
|
2022-05-16 23:48:22 +00:00
|
|
|
box = tuple(surf.get_bounding_rect())
|
|
|
|
whitespace_dict[path] = box
|
|
|
|
return box
|
|
|
|
|
|
|
|
def crop_image_zoom(path, xsize, ysize, grayscale=False):
|
|
|
|
x, y, w, h = crop_whitespace(path)
|
|
|
|
matrix = SaturationMatrix(0) if grayscale else None
|
|
|
|
sprite = Image(path)
|
|
|
|
|
|
|
|
return Transform(sprite, crop=(x, y, w, h), xsize=xsize, ysize=ysize, fit="contain", matrixcolor=matrix, subpixel=True)
|
|
|
|
|
|
|
|
def get_zoom(image, size):
|
2022-09-21 20:57:04 +00:00
|
|
|
if isinstance(image, str):
|
2022-05-16 23:48:22 +00:00
|
|
|
image = Image(image)
|
|
|
|
|
|
|
|
r = renpy.render(image, 800, 800, 0, 0)
|
|
|
|
x, y = r.get_size()
|
|
|
|
xsize, ysize = size
|
|
|
|
|
|
|
|
return min(ysize / y, xsize / x)
|