mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-24 10:11:57 -04:00
multi scale; fix scale
This commit is contained in:
parent
8e71037f5f
commit
46a7db90e0
|
@ -16,6 +16,8 @@ class CursorImage:
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'CursorImage(image={self.image!r}, hotspot={self.hotspot!r}, nominal={self.nominal!r})'
|
return f'CursorImage(image={self.image!r}, hotspot={self.hotspot!r}, nominal={self.nominal!r})'
|
||||||
|
|
||||||
|
def clone(self):
|
||||||
|
return CursorImage(self.image.clone(), self.hotspot, self.nominal)
|
||||||
|
|
||||||
class CursorFrame:
|
class CursorFrame:
|
||||||
images: List[CursorImage]
|
images: List[CursorImage]
|
||||||
|
@ -36,3 +38,6 @@ class CursorFrame:
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'CursorFrame(images={self.images!r}, delay={self.delay!r})'
|
return f'CursorFrame(images={self.images!r}, delay={self.delay!r})'
|
||||||
|
|
||||||
|
def clone(self):
|
||||||
|
return CursorFrame([img.clone() for img in self.images], self.delay)
|
||||||
|
|
|
@ -32,8 +32,8 @@ def main() -> None:
|
||||||
help='y-offset of shadow (as fraction of height)')
|
help='y-offset of shadow (as fraction of height)')
|
||||||
parser.add_argument('-c', '--shadow-color', default='#000000',
|
parser.add_argument('-c', '--shadow-color', default='#000000',
|
||||||
help='color of the shadow')
|
help='color of the shadow')
|
||||||
parser.add_argument('--scale', default=None, type=float,
|
parser.add_argument('--scale', default=None, type=str,
|
||||||
help='Scale the cursor by the specified factor.')
|
help='Scale the cursor by the specified factor. Multi-scale "[0.125.0.1875,0.25]"')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print_lock = Lock()
|
print_lock = Lock()
|
||||||
|
@ -49,7 +49,11 @@ def main() -> None:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
else:
|
else:
|
||||||
if args.scale:
|
if args.scale:
|
||||||
scale.apply_to_frames(cursor.frames, scale=args.scale)
|
scales = eval(args.scale)
|
||||||
|
if isinstance(scales, (int, float)):
|
||||||
|
scale.apply_to_frames(cursor.frames, scale=scales)
|
||||||
|
else:
|
||||||
|
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales)
|
||||||
if args.shadow:
|
if args.shadow:
|
||||||
shadow.apply_to_frames(cursor.frames, color=args.shadow_color, radius=args.shadow_radius,
|
shadow.apply_to_frames(cursor.frames, color=args.shadow_color, radius=args.shadow_radius,
|
||||||
sigma=args.shadow_sigma, xoffset=args.shadow_x, yoffset=args.shadow_y)
|
sigma=args.shadow_sigma, xoffset=args.shadow_x, yoffset=args.shadow_y)
|
||||||
|
|
|
@ -8,5 +8,16 @@ def apply_to_frames(frames: List[CursorFrame], *, scale: float) -> None:
|
||||||
for cursor in frame:
|
for cursor in frame:
|
||||||
cursor.image.scale(
|
cursor.image.scale(
|
||||||
int(round(cursor.image.width * scale)),
|
int(round(cursor.image.width * scale)),
|
||||||
int(round(cursor.image.height) * scale),
|
int(round(cursor.image.height * scale)),
|
||||||
)
|
)
|
||||||
|
cursor.nominal = int(cursor.nominal * scale)
|
||||||
|
hx, hy = cursor.hotspot
|
||||||
|
cursor.hotspot = (int(hx * scale), int(hy * scale))
|
||||||
|
|
||||||
|
def apply_to_frames_MS(frames: List[CursorFrame], *, scales: List[float]) -> List[CursorFrame]:
|
||||||
|
frames_MS = []
|
||||||
|
for scale in scales:
|
||||||
|
frames_s = [frame.clone() for frame in frames]
|
||||||
|
apply_to_frames(frames_s, scale=scale)
|
||||||
|
frames_MS.extend(frames_s)
|
||||||
|
return frames_MS
|
Loading…
Reference in a new issue