feat: add image-svg icon
This commit is contained in:
1 parent
3e472acfb8
commit
bcd3f06ee9
1 file changed
+48
@@ -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)
|
||||
Reference in new issue
Block a user