mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-24 10:11:57 -04:00
multi size
This commit is contained in:
parent
f46196f851
commit
133e509929
|
@ -33,7 +33,9 @@ def main() -> None:
|
||||||
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=str,
|
parser.add_argument('--scale', default=None, type=str,
|
||||||
help='Scale the cursor by the specified factor. Multi-scale "[0.125.0.1875,0.25]"')
|
help='Scale the cursor by the specified factor. Multi-scale "[0.125,0.1875,0.25]"')
|
||||||
|
parser.add_argument('--size', default=None, type=str,
|
||||||
|
help='Scale the cursor to the specified size. Multi-size "[32,28,64]"')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print_lock = Lock()
|
print_lock = Lock()
|
||||||
|
@ -54,6 +56,13 @@ def main() -> None:
|
||||||
scale.apply_to_frames(cursor.frames, scale=scales)
|
scale.apply_to_frames(cursor.frames, scale=scales)
|
||||||
else:
|
else:
|
||||||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales)
|
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales)
|
||||||
|
elif args.size:
|
||||||
|
sizes = eval(args.size)
|
||||||
|
if isinstance(sizes, (int, float)):
|
||||||
|
scale.apply_to_frames(cursor.frames, size=sizes)
|
||||||
|
else:
|
||||||
|
cursor.frames = scale.apply_to_frames_MS(cursor.frames, sizes=sizes)
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -19,7 +19,9 @@ def main() -> None:
|
||||||
parser.add_argument('-o', '--output', '--output-dir', default=os.curdir,
|
parser.add_argument('-o', '--output', '--output-dir', default=os.curdir,
|
||||||
help='Directory to store converted cursor files.')
|
help='Directory to store converted cursor files.')
|
||||||
parser.add_argument('-S', '--scale', default=None, type=str,
|
parser.add_argument('-S', '--scale', default=None, type=str,
|
||||||
help='Scale the cursor by the specified factor. Multi-scale "[0.125.0.1875,0.25]"')
|
help='Scale the cursor by the specified factor. Multi-scale "[0.125,0.1875,0.25]"')
|
||||||
|
parser.add_argument('--size', default=None, type=str,
|
||||||
|
help='Scale the cursor to the specified size. Multi-size "[32,28,64]"')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print_lock = Lock()
|
print_lock = Lock()
|
||||||
|
@ -40,6 +42,13 @@ def main() -> None:
|
||||||
scale.apply_to_frames(cursor.frames, scale=scales)
|
scale.apply_to_frames(cursor.frames, scale=scales)
|
||||||
else:
|
else:
|
||||||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales)
|
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales)
|
||||||
|
elif args.size:
|
||||||
|
sizes = eval(args.size)
|
||||||
|
if isinstance(sizes, (int, float)):
|
||||||
|
scale.apply_to_frames(cursor.frames, size=sizes)
|
||||||
|
else:
|
||||||
|
cursor.frames = scale.apply_to_frames_MS(cursor.frames, sizes=sizes)
|
||||||
|
|
||||||
ext, result = to_smart(cursor.frames)
|
ext, result = to_smart(cursor.frames)
|
||||||
output = os.path.join(args.output, os.path.basename(name) + ext)
|
output = os.path.join(args.output, os.path.basename(name) + ext)
|
||||||
with open(output, 'wb') as f:
|
with open(output, 'wb') as f:
|
||||||
|
|
|
@ -3,21 +3,31 @@ from typing import List
|
||||||
from win2xcur.cursor import CursorFrame
|
from win2xcur.cursor import CursorFrame
|
||||||
|
|
||||||
|
|
||||||
def apply_to_frames(frames: List[CursorFrame], *, scale: float) -> None:
|
def apply_to_frames(frames: List[CursorFrame], *, scale: float = None, size: int = None) -> None:
|
||||||
for frame in frames:
|
for frame in frames:
|
||||||
for cursor in frame:
|
for cursor in frame:
|
||||||
|
if size:
|
||||||
|
scale = size / cursor.image.width
|
||||||
cursor.image.scale(
|
cursor.image.scale(
|
||||||
int(round(cursor.image.width * scale)),
|
size or int(round(cursor.image.width * scale)),
|
||||||
int(round(cursor.image.height * scale)),
|
size or int(round(cursor.image.height * scale)),
|
||||||
)
|
)
|
||||||
cursor.nominal = int(cursor.nominal * scale)
|
cursor.nominal = int(cursor.nominal * scale)
|
||||||
hx, hy = cursor.hotspot
|
hx, hy = cursor.hotspot
|
||||||
cursor.hotspot = (int(hx * scale), int(hy * scale))
|
cursor.hotspot = (int(hx * scale), int(hy * scale))
|
||||||
|
|
||||||
def apply_to_frames_MS(frames: List[CursorFrame], *, scales: List[float]) -> List[CursorFrame]:
|
|
||||||
|
def apply_to_frames_MS(frames: List[CursorFrame], *, scales: List[float] = None,
|
||||||
|
sizes: List[int] = None) -> List[CursorFrame]:
|
||||||
frames_MS = []
|
frames_MS = []
|
||||||
|
if scales is not None:
|
||||||
for scale in scales:
|
for scale in scales:
|
||||||
frames_s = [frame.clone() for frame in frames]
|
frames_s = [frame.clone() for frame in frames]
|
||||||
apply_to_frames(frames_s, scale=scale)
|
apply_to_frames(frames_s, scale=scale)
|
||||||
frames_MS.extend(frames_s)
|
frames_MS.extend(frames_s)
|
||||||
|
else:
|
||||||
|
for size in sizes:
|
||||||
|
frames_s = [frame.clone() for frame in frames]
|
||||||
|
apply_to_frames(frames_s, size=size)
|
||||||
|
frames_MS.extend(frames_s)
|
||||||
return frames_MS
|
return frames_MS
|
Loading…
Reference in a new issue