mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-25 02:31:56 -04:00
feat: multiscale
This commit is contained in:
parent
5e45771d7f
commit
88918764b1
32
win2xcur/multiscale.py
Normal file
32
win2xcur/multiscale.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from win2xcur.cursor import CursorFrame, CursorImage
|
||||||
|
|
||||||
|
MULTSCALE = [16, 24, 32, 48, 64, 96, 128, 192, 256]
|
||||||
|
|
||||||
|
def generates_frames(cursor, min_size: int) -> None:
|
||||||
|
"""Generates multiple sizes for each cursor.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
cursor (Cursor): The cursor to generate sizes for.
|
||||||
|
min_size (int): The minimum size to generate.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[Cursor]: The generated cursors.
|
||||||
|
"""
|
||||||
|
frames = cursor.frames
|
||||||
|
new_frames = []
|
||||||
|
image_size = frames[0].images[0].nominal
|
||||||
|
for size in MULTSCALE:
|
||||||
|
if size > image_size:
|
||||||
|
continue
|
||||||
|
if size < min_size:
|
||||||
|
break
|
||||||
|
for frame in frames:
|
||||||
|
new_images = []
|
||||||
|
for cur in frame:
|
||||||
|
new_cur = CursorImage(cur.image.clone(), cur.hotspot, cur.nominal)
|
||||||
|
new_cur.scale(size, size)
|
||||||
|
new_images.append(new_cur)
|
||||||
|
new_frame = CursorFrame(new_images, frame.delay)
|
||||||
|
new_frames.append(new_frame)
|
||||||
|
del cursor.frames[:]
|
||||||
|
cursor.frames.extend(new_frames)
|
Loading…
Reference in a new issue