Add cursor rotation

This commit is contained in:
Mike L 2025-05-04 18:38:41 +02:00
parent 32270a18f3
commit 86edaa4b67
Signed by: mikeslab
GPG key ID: 48CCD1768D862D40

View file

@ -102,6 +102,7 @@ def main():
} }
hidpiRatio = 2 if capeConfig['HiDPI'] else 1 hidpiRatio = 2 if capeConfig['HiDPI'] else 1
width, height = cursorConfig.get('Size', (-1.0, -1.0)) width, height = cursorConfig.get('Size', (-1.0, -1.0))
rotation = cursorConfig.pop('Rotation', 0)
with open(cursorConfig['Path'], 'rb') as f: with open(cursorConfig['Path'], 'rb') as f:
spriteSheet = None spriteSheet = None
@ -111,6 +112,7 @@ def main():
for frameIndex in range(len(res['msg'])): for frameIndex in range(len(res['msg'])):
b = io.BytesIO(res['msg'][frameIndex]) b = io.BytesIO(res['msg'][frameIndex])
frame, (width, height) = readCUR(b, width, height) frame, (width, height) = readCUR(b, width, height)
frame = frame.rotate(rotation)
position = (2, 2 + int((height + 4) * frameIndex)) position = (2, 2 + int((height + 4) * frameIndex))
if frameIndex == 0: if frameIndex == 0:
spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4) * len(res['msg']))) spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4) * len(res['msg'])))
@ -118,6 +120,7 @@ def main():
else: else:
logging.info('尝试作为CUR读入') logging.info('尝试作为CUR读入')
frame, (width, height) = readCUR(f, width, height) frame, (width, height) = readCUR(f, width, height)
frame = frame.rotate(rotation)
spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4))) spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4)))
spriteSheet.paste(frame, (2, 2)) spriteSheet.paste(frame, (2, 2))
logging.info(f'目标尺寸:{width}x{height}@{hidpiRatio}x') logging.info(f'目标尺寸:{width}x{height}@{hidpiRatio}x')