fix: fix build issue
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from .assemblicon.context import Context
|
||||
from .assemblicon.context import Prerequisite, Context, AdvancedContext, SvgRenderKind
|
||||
from .assemblicon.utils import setup_logging
|
||||
from .std_icons import build_standard_icons
|
||||
from .ext_icons import build_ext_icons
|
||||
from .nostd_icons import build_non_standard_icons
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -12,14 +12,16 @@ def main() -> None:
|
||||
repository_root = Path(__file__).resolve().parent.parent.parent.parent
|
||||
iconset_input = repository_root / "src"
|
||||
iconset_output = repository_root / "artifact"
|
||||
ctx = Context(iconset_input, iconset_output)
|
||||
prereq = Prerequisite(iconset_input, iconset_output, SvgRenderKind.Inkscape)
|
||||
ctx = Context(prereq)
|
||||
advctx = AdvancedContext(ctx)
|
||||
|
||||
try:
|
||||
_build_icons(ctx)
|
||||
_build_icons(advctx)
|
||||
except BaseException as e:
|
||||
logging.fatal("Runtime error: %s", e)
|
||||
|
||||
|
||||
def _build_icons(ctx: Context) -> None:
|
||||
def _build_icons(ctx: AdvancedContext) -> None:
|
||||
build_standard_icons(ctx)
|
||||
#build_ext_icons(ctx)
|
||||
build_non_standard_icons(ctx)
|
||||
|
||||
@@ -207,7 +207,7 @@ class AdvancedContext:
|
||||
self.__intern_render_svg(src, dst, cfg)
|
||||
|
||||
def render_svg_then_load(
|
||||
self, src: Path, dst: Optional[Path], cfg: SvgConfig = _DEFAULT_SVG_CONFIG
|
||||
self, src: Path, dst: Optional[Path] = None, cfg: SvgConfig = _DEFAULT_SVG_CONFIG
|
||||
) -> Artifact:
|
||||
"""
|
||||
Render given SVG to PNG file, then load it directly.
|
||||
@@ -248,7 +248,7 @@ class AdvancedContext:
|
||||
self.__intern_render_blender(src, dst, cfg)
|
||||
|
||||
def render_blender_then_load(
|
||||
self, src: Path, dst: Optional[Path], cfg: BlenderConfig = _DEFAULT_BLD_CONFIG
|
||||
self, src: Path, dst: Optional[Path] = None, cfg: BlenderConfig = _DEFAULT_BLD_CONFIG
|
||||
) -> Artifact:
|
||||
"""
|
||||
Render given Blender composition to PNG file, then load it directly.
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
from ..assemblicon.context import Context
|
||||
from .image_icons import build_image_icons
|
||||
|
||||
|
||||
def build_ext_icons(ctx: Context) -> None:
|
||||
build_image_icons(ctx)
|
||||
@@ -1,5 +1,6 @@
|
||||
from ..assemblicon.context import Context
|
||||
from ..assemblicon.context import AdvancedContext
|
||||
from .mimetype_icons import build_mimetype_icons
|
||||
|
||||
|
||||
def build_non_standard_icons(ctx: Context) -> None:
|
||||
pass
|
||||
def build_non_standard_icons(ctx: AdvancedContext) -> None:
|
||||
build_mimetype_icons(ctx)
|
||||
|
||||
+17
-13
@@ -1,7 +1,6 @@
|
||||
import PIL.Image
|
||||
import PIL.ImageEnhance
|
||||
from ..assemblicon.artrender import render_svg, render_ico, SvgConfig
|
||||
from ..assemblicon.context import Context
|
||||
from ..assemblicon.context import AdvancedContext, FdContext, WinCategory, MacCategory
|
||||
from ..assemblicon.utils import Artifact
|
||||
from ..assemblicon.geometry import MinMaxRect, PosSizeRect
|
||||
from ..assemblicon.artio import load_input_artifact, save_artifact
|
||||
@@ -11,23 +10,26 @@ from ..assemblicon.artproc import (
|
||||
HorizontalAnchor,
|
||||
)
|
||||
|
||||
|
||||
def build_mimetype_icons(ctx: AdvancedContext) -> None:
|
||||
_build_image_icons(ctx)
|
||||
|
||||
|
||||
IMAGE_INNER_RECT_MINMAX = MinMaxRect(20 * 4, 52 * 4, 236 * 4, 204 * 4)
|
||||
IMAGE_INNER_RECT_POSSIZE = IMAGE_INNER_RECT_MINMAX.to_pos_size_rect()
|
||||
|
||||
|
||||
def build_image_icons(ctx: Context) -> None:
|
||||
def _build_image_icons(ctx: AdvancedContext) -> None:
|
||||
# build image base
|
||||
image_base = render_svg(
|
||||
image_base = ctx.render_svg_then_load(
|
||||
ctx.input_artifact("component", "image-base.svg"),
|
||||
ctx.temporary_artifact("component", "image-base.png"),
|
||||
SvgConfig(1024, 1024),
|
||||
)
|
||||
# load image base
|
||||
with image_base:
|
||||
_build_jpg_icon(ctx, image_base)
|
||||
|
||||
|
||||
def _build_jpg_icon(ctx: Context, base: Artifact) -> None:
|
||||
def _build_jpg_icon(ctx: AdvancedContext, base: Artifact) -> None:
|
||||
jpg_image = base.copy()
|
||||
|
||||
jpg_image_inner = load_input_artifact(
|
||||
@@ -58,10 +60,12 @@ def _build_jpg_icon(ctx: Context, base: Artifact) -> None:
|
||||
jpg_image.paste(
|
||||
bestfit_jpg_image_inner, IMAGE_INNER_RECT_POSSIZE.to_pillow_tuple()
|
||||
)
|
||||
|
||||
# build artifacts
|
||||
save_artifact(jpg_image, ctx.temporary_artifact("ext", "jpg-image.png"))
|
||||
render_ico(
|
||||
ctx,
|
||||
jpg_image,
|
||||
ctx.output_artifact("ext", "jpg-image.ico"),
|
||||
)
|
||||
# save for FD
|
||||
ctx.save_fd_artifact(jpg_image, FdContext.MimeTypes, "image-jpeg")
|
||||
# use image/jpeg as the default image icon
|
||||
ctx.dup_fd_artifact(FdContext.MimeTypes, "image-jpeg", FdContext.MimeTypes, "image-x-generic")
|
||||
# save for windows and mac
|
||||
ctx.save_win_artifact(jpg_image, WinCategory.Extension, "jpg")
|
||||
ctx.save_mac_artifact(jpg_image, MacCategory.Extension, "jpg")
|
||||
@@ -1,6 +1,6 @@
|
||||
from ..assemblicon.context import Context
|
||||
from ..assemblicon.context import AdvancedContext
|
||||
from .action_icons import build_action_icons
|
||||
|
||||
|
||||
def build_standard_icons(ctx: Context) -> None:
|
||||
def build_standard_icons(ctx: AdvancedContext) -> None:
|
||||
build_action_icons(ctx)
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
from pathlib import Path
|
||||
import PIL.Image
|
||||
from ..assemblicon.artrender import render_svg, SvgConfig
|
||||
from ..assemblicon.context import Context
|
||||
from ..assemblicon.utils import Artifact
|
||||
from ..assemblicon.artio import save_artifact
|
||||
from ..assemblicon.context import AdvancedContext, FdContext
|
||||
|
||||
|
||||
def build_action_icons(ctx: Context) -> None:
|
||||
def build_action_icons(ctx: AdvancedContext) -> None:
|
||||
_build_go_icons(ctx)
|
||||
|
||||
|
||||
def _build_go_icons(ctx: Context) -> None:
|
||||
def _build_go_icons(ctx: AdvancedContext) -> None:
|
||||
# build go-* base
|
||||
go_base = render_svg(
|
||||
ctx.input_artifact("component", "go-base.svg"),
|
||||
ctx.temporary_artifact("component", "go-base.png"),
|
||||
SvgConfig(1024, 1024),
|
||||
go_base = ctx.render_svg_then_load(
|
||||
ctx.input_artifact("component", "go-base.svg")
|
||||
)
|
||||
# build go-* shining
|
||||
go_inner_shining = render_svg(
|
||||
go_inner_shining = ctx.render_svg_then_load(
|
||||
ctx.input_artifact("component", "go-inner-shining.svg"),
|
||||
ctx.temporary_artifact("component", "go-inner-shining.png"),
|
||||
SvgConfig(1024, 1024),
|
||||
)
|
||||
# build go-* inner
|
||||
go_inner = render_svg(
|
||||
go_inner = ctx.render_svg_then_load(
|
||||
ctx.input_artifact("component", "go-inner.svg"),
|
||||
ctx.temporary_artifact("component", "go-inner.png"),
|
||||
SvgConfig(1024, 1024),
|
||||
)
|
||||
|
||||
with go_base, go_inner_shining, go_inner:
|
||||
@@ -36,8 +26,9 @@ def _build_go_icons(ctx: Context) -> None:
|
||||
go = go_base.copy()
|
||||
# render shining with inner mask
|
||||
go.paste(go_inner_shining, (0, 0), go_mask)
|
||||
# save as image
|
||||
save_artifact(go, ctx.output_artifact(f"go-{part}.png"))
|
||||
|
||||
# save as FD action
|
||||
ctx.save_fd_artifact(go, FdContext.Actions, f'go-{part}')
|
||||
|
||||
# rotate it for next calling
|
||||
go_mask = go_mask.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||
|
||||
Reference in New Issue
Block a user