mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-06-07 13:29:37 -04:00
Merge 10804a68c8
into 8e71037f5f
This commit is contained in:
commit
e686d3750e
|
@ -28,13 +28,13 @@ For example, if you want to convert [the sample cursor](sample/crosshair.cur)
|
||||||
to Linux format:
|
to Linux format:
|
||||||
|
|
||||||
mkdir output/
|
mkdir output/
|
||||||
win2xcur sample/crosshair.cur -o output/
|
win2xcur sample/crosshair.cur -o output/ --size 32 48 64
|
||||||
|
|
||||||
`-s` can be specified to enable shadows.
|
`-s` can be specified to enable shadows.
|
||||||
Multiple cursors files can be specified on the command line.
|
Multiple cursors files can be specified on the command line.
|
||||||
For example, to convert a directory of cursors with shadows enabled:
|
For example, to convert a directory of cursors with shadows enabled:
|
||||||
|
|
||||||
win2xcur input/*.{ani,cur} -o output/
|
win2xcur input/*.{ani,cur} -o output/ --size 32 48 64
|
||||||
|
|
||||||
For more information, run `win2xcur --help`.
|
For more information, run `win2xcur --help`.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ For more information, run `win2xcur --help`.
|
||||||
For example, if you want to convert DMZ-White to Windows:
|
For example, if you want to convert DMZ-White to Windows:
|
||||||
|
|
||||||
mkdir dmz-white/
|
mkdir dmz-white/
|
||||||
x2wincur /usr/share/icons/DMZ-White/cursors/* -o dmz-white/
|
x2wincur /usr/share/icons/DMZ-White/cursors/* -o dmz-white/ --size 32 48 64
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|
|
@ -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,10 @@ 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', nargs='*', type=float, default=None,
|
||||||
help='Scale the cursor by the specified factor.')
|
help='Scale the cursor by the specified factor. Multi-scale "[0.125,0.1875,0.25]"')
|
||||||
|
parser.add_argument('--size', nargs='*', type=int, default=None,
|
||||||
|
help='Scale the cursor to the specified size. Multi-size "[32,48,64]"')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print_lock = Lock()
|
print_lock = Lock()
|
||||||
|
@ -49,7 +51,12 @@ 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)
|
cursor.frames = scale.apply_to_frames_by_scales(cursor.frames, scales=args.scale)
|
||||||
|
elif args.size:
|
||||||
|
cursor.frames = scale.apply_to_frames_to_sizes(cursor.frames, sizes=args.size)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError('Please specify either --scale or --size')
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -18,8 +18,10 @@ def main() -> None:
|
||||||
help='X11 cursor files to convert (no extension)')
|
help='X11 cursor files to convert (no extension)')
|
||||||
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=float,
|
parser.add_argument('-S', '--scale', nargs='*', type=float, default=None,
|
||||||
help='Scale the cursor by the specified factor.')
|
help='Scale the cursor by the specified factor. Multi-scale "[0.125,0.1875,0.25]"')
|
||||||
|
parser.add_argument('--size', nargs='*', type=int, default=None,
|
||||||
|
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()
|
||||||
|
@ -35,7 +37,12 @@ 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)
|
cursor.frames = scale.apply_to_frames_by_scales(cursor.frames, scales=args.scale)
|
||||||
|
elif args.size:
|
||||||
|
cursor.frames = scale.apply_to_frames_to_sizes(cursor.frames, sizes=args.size)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError('Please specify either --scale or --size')
|
||||||
|
|
||||||
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:
|
||||||
|
|
|
@ -2,11 +2,35 @@ from typing import List
|
||||||
|
|
||||||
from win2xcur.cursor import CursorFrame
|
from win2xcur.cursor import CursorFrame
|
||||||
|
|
||||||
|
def apply_to_frames_by_scales(frames: List[CursorFrame], *, scales: List[float] = None) -> List[CursorFrame]:
|
||||||
|
all_frames = []
|
||||||
|
for scale in scales:
|
||||||
|
for frame in frames:
|
||||||
|
frame = frame.clone()
|
||||||
|
for cursor in frame:
|
||||||
|
cursor.image.scale(
|
||||||
|
int(round(cursor.image.width * 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))
|
||||||
|
all_frames.append(frame)
|
||||||
|
return all_frames
|
||||||
|
|
||||||
def apply_to_frames(frames: List[CursorFrame], *, scale: float) -> None:
|
def apply_to_frames_to_sizes(frames: List[CursorFrame], *, sizes: List[int] = None) -> List[CursorFrame]:
|
||||||
for frame in frames:
|
all_frames = []
|
||||||
for cursor in frame:
|
for size in sizes:
|
||||||
cursor.image.scale(
|
for frame in frames:
|
||||||
int(round(cursor.image.width * scale)),
|
frame = frame.clone()
|
||||||
int(round(cursor.image.height) * scale),
|
for cursor in frame:
|
||||||
)
|
scale = size / cursor.image.width
|
||||||
|
cursor.image.scale(
|
||||||
|
size,
|
||||||
|
size,
|
||||||
|
)
|
||||||
|
cursor.nominal = int(cursor.nominal * scale)
|
||||||
|
hx, hy = cursor.hotspot
|
||||||
|
cursor.hotspot = (int(hx * scale), int(hy * scale))
|
||||||
|
all_frames.append(frame)
|
||||||
|
return all_frames
|
||||||
|
|
Loading…
Reference in a new issue