feat: bring source and sink back for future development
This commit is contained in:
@@ -17,6 +17,8 @@ def main() -> None:
|
||||
env = Environment(prologue)
|
||||
ctx = Context(env)
|
||||
|
||||
# TODO: use explicit temporary directory initializer in prologue to do this.
|
||||
|
||||
# create our special temporary subdirectory
|
||||
env.temporary_artifact("component").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ _DEFAULT_BLD_CONFIG = artrdr.BlenderConfig(VART_HW, VART_HW)
|
||||
|
||||
# TODO: For easy testing, we only build 32x32 and 48x48.
|
||||
# Enable full generation after testing.
|
||||
_FD_THUMBNAIL_HWS: tuple[int, ...] = (32, 48, 256)
|
||||
_FD_THUMBNAIL_HWS: tuple[int, ...] = (32, 48)
|
||||
# _FD_THUMBNAIL_HWS: tuple[int, ...] = (16, 32, 48, 64, 128, 256)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
from .common import Sink
|
||||
from .tempdir_sink import TempDirSink
|
||||
|
||||
__all__ = [
|
||||
"Sink",
|
||||
"TempDirSink"
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..utils import Artifact
|
||||
|
||||
class Sink(ABC):
|
||||
"""
|
||||
Abstract base class for all sinks.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def push_artifact(self, art: Artifact) -> None:
|
||||
pass
|
||||
@@ -0,0 +1,12 @@
|
||||
from ..utils import Artifact
|
||||
from .common import Sink
|
||||
|
||||
class TempDirSink(Sink):
|
||||
|
||||
__args: tuple[str, ...]
|
||||
|
||||
def __init__(self, *args: str) -> None:
|
||||
self.__args = tuple(args)
|
||||
|
||||
def push_artifact(self, art: Artifact) -> None:
|
||||
pass
|
||||
@@ -0,0 +1,7 @@
|
||||
from .common import Source
|
||||
from .tempdir_source import TempDirSource
|
||||
|
||||
__all__ = [
|
||||
"Source",
|
||||
"TempDirSource"
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..utils import Artifact
|
||||
|
||||
class Source(ABC):
|
||||
"""
|
||||
Abstract base class for all sources.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def pull_artifact(self) -> Artifact:
|
||||
pass
|
||||
@@ -0,0 +1,12 @@
|
||||
from ..utils import Artifact
|
||||
from .common import Source
|
||||
|
||||
class TempDirSource(Source):
|
||||
|
||||
__path_comps: tuple[str, ...]
|
||||
|
||||
def __init__(self, *args: str) -> None:
|
||||
self.__path_comps = tuple(args)
|
||||
|
||||
def pull_artifact(self) -> Artifact:
|
||||
pass
|
||||
@@ -1,5 +1,6 @@
|
||||
import enum
|
||||
import math
|
||||
import PIL.Image
|
||||
from .utils import Artifact
|
||||
from ..geometry import Point
|
||||
|
||||
@@ -73,6 +74,13 @@ def aspect_ratio_scale_and_crop(
|
||||
return scaled.crop((crop_x, crop_y, crop_x + target_width, crop_y + target_height))
|
||||
|
||||
|
||||
def default_art_resize(art: Artifact, width: int, height: int) -> Artifact:
|
||||
"""
|
||||
Resize given artifact with default resample (LANCZOS).
|
||||
"""
|
||||
return art.resize((width, height), PIL.Image.Resampling.LANCZOS)
|
||||
|
||||
|
||||
def art_anchor_to_offset(
|
||||
art: Artifact,
|
||||
horizontal_anchor: HorizontalAnchor,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import PIL.Image
|
||||
from ..types import AuroraContext, AuroraEnvironment
|
||||
from ..assemblicon.highlevel.environment import FdContext
|
||||
from ..assemblicon.highlevel.utils import VART_HW
|
||||
from ..assemblicon.geometry import Rectangle, Point
|
||||
from ..assemblicon.geometry import Rectangle
|
||||
from ..assemblicon.lowlevel.artproc import (
|
||||
art_anchor_to_offset,
|
||||
anchor_to_offset,
|
||||
default_art_resize,
|
||||
align_paste,
|
||||
align_alpha_composite,
|
||||
VerticalAnchor,
|
||||
@@ -30,7 +30,7 @@ def build_image_properties_icon(env: AuroraEnvironment) -> None:
|
||||
art = env.load_temporary_artifact("image-jpeg.png")
|
||||
|
||||
info_mark = env.load_temporary_artifact("dialog-infomation.png")
|
||||
resized_info_mark = info_mark.resize((500, 500), PIL.Image.Resampling.LANCZOS)
|
||||
resized_info_mark = default_art_resize(info_mark, 500, 500)
|
||||
|
||||
align_alpha_composite(
|
||||
art,
|
||||
@@ -47,23 +47,23 @@ def build_image_properties_icon(env: AuroraEnvironment) -> None:
|
||||
|
||||
def build_image_zoom_original_icon(env: AuroraEnvironment) -> None:
|
||||
# load triangle assets
|
||||
tri_new_size = (200, 200)
|
||||
tri_left = env.load_temporary_artifact("component", "triangle-left.png").resize(
|
||||
tri_new_size, PIL.Image.Resampling.LANCZOS
|
||||
TRI_SIZE = (200, 200)
|
||||
tri_left = default_art_resize(
|
||||
env.load_temporary_artifact("component", "triangle-left.png"), *TRI_SIZE
|
||||
)
|
||||
tri_down = env.load_temporary_artifact("component", "triangle-down.png").resize(
|
||||
tri_new_size, PIL.Image.Resampling.LANCZOS
|
||||
tri_down = default_art_resize(
|
||||
env.load_temporary_artifact("component", "triangle-down.png"), *TRI_SIZE
|
||||
)
|
||||
tri_right = env.load_temporary_artifact("component", "triangle-right.png").resize(
|
||||
tri_new_size, PIL.Image.Resampling.LANCZOS
|
||||
tri_right = default_art_resize(
|
||||
env.load_temporary_artifact("component", "triangle-right.png"), *TRI_SIZE
|
||||
)
|
||||
tri_up = env.load_temporary_artifact("component", "triangle-up.png").resize(
|
||||
tri_new_size, PIL.Image.Resampling.LANCZOS
|
||||
tri_up = default_art_resize(
|
||||
env.load_temporary_artifact("component", "triangle-up.png"), *TRI_SIZE
|
||||
)
|
||||
|
||||
# load inner image
|
||||
inner = env.load_temporary_artifact("image-jpeg.png")
|
||||
resized_inner = inner.resize((680, 680), PIL.Image.Resampling.LANCZOS)
|
||||
resized_inner = default_art_resize(inner, 680, 680)
|
||||
|
||||
# composite this icon
|
||||
icon = env.new_artifact()
|
||||
|
||||
@@ -3,6 +3,7 @@ from ..types import AuroraContext, AuroraEnvironment
|
||||
from ..assemblicon.highlevel.environment import FdContext, WinCategory, MacCategory
|
||||
from ..assemblicon.lowlevel.artproc import (
|
||||
art_anchor_to_offset,
|
||||
default_art_resize,
|
||||
align_paste,
|
||||
VerticalAnchor,
|
||||
HorizontalAnchor,
|
||||
@@ -24,7 +25,7 @@ def build_sarasacw_picture_icons(env: AuroraEnvironment) -> None:
|
||||
)
|
||||
|
||||
inner = env.load_temporary_artifact("image-jpeg.png")
|
||||
resized_inner = inner.resize((990, 990), PIL.Image.Resampling.LANCZOS)
|
||||
resized_inner = default_art_resize(inner, 990, 990)
|
||||
|
||||
align_paste(
|
||||
app,
|
||||
|
||||
Reference in New Issue
Block a user