From bcd3f06ee93447e13e7c8087c169b90d83c6c7b5 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Mon, 19 Oct 2026 11:02:15 +0800 Subject: [PATCH] feat: add image-svg icon --- .../std_icons/mimetype_icons.py | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tool/src/aurora_iconset_builder/std_icons/mimetype_icons.py b/tool/src/aurora_iconset_builder/std_icons/mimetype_icons.py index c23e2d3..dfd69d7 100644 --- a/tool/src/aurora_iconset_builder/std_icons/mimetype_icons.py +++ b/tool/src/aurora_iconset_builder/std_icons/mimetype_icons.py @@ -9,6 +9,7 @@ from assemblicon.highlevel.utils import ( ) from assemblicon.highlevel.source import ( SvgSource, + BlenderSource, BitmapSource, TempArtSource, FdArtSource, @@ -97,6 +98,18 @@ def register(ctx: AuroraContext) -> None: ), build_image_gif_icon, ) + ctx.register( + "std/mimetype/image-svg", + ( + TempArtSource("component", "image-base.png"), + BlenderSource("exts", "vector-image-inner.blend"), + FdArtSink(FdContext.MimeTypes, "image-svg"), + IcoArtSink(IcoCategory.Extension, "svg"), + MsixArtSink(MsixCategory.Extension, "svg"), + IcnsArtSink(IcnsCategory.Extension, "svg"), + ), + build_image_svg_icon, + ) def build_image_base_icon( @@ -289,3 +302,38 @@ def build_image_gif_icon( ico_sink.push(env, gif_image) msix_sink.push(env, gif_image) icns_sink.push(env, gif_image) + + +def build_image_svg_icon( + env: AuroraEnvironment, + base_src: TempArtSource, + blender_src: BlenderSource, + fd_sink: FdArtSink, + ico_sink: IcoArtSink, + msix_sink: MsixArtSink, + icns_sink: IcnsArtSink, +) -> None: + svg_image = base_src.pull(env) + + svg_image_inner = blender_src.pull(env) + with svg_image_inner: + # we use the whole image as the inner, + # so we directly fit it to inner. + bestfit_inner = aspect_ratio_scale_and_crop( + svg_image_inner, + IMAGE_INNER_RECT.width, + IMAGE_INNER_RECT.height, + PIL.Image.Resampling.NEAREST, + HorizontalAnchor.Center, + VerticalAnchor.Center, + ) + # paste into inner rect + svg_image.paste(bestfit_inner, IMAGE_INNER_RECT.to_tuple()) + + # build artifacts + # save for FD + fd_sink.push(env, svg_image) + # save for windows and mac + ico_sink.push(env, svg_image) + msix_sink.push(env, svg_image) + icns_sink.push(env, svg_image)