Browse Source

Add cursor rotation

Mike L 1 month ago
parent
commit
86edaa4b67
1 changed files with 3 additions and 0 deletions
  1. 3 0
      ani2cape.py

+ 3 - 0
ani2cape.py

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