feat: add zoom-original
This commit is contained in:
@@ -2,6 +2,7 @@ import PIL.Image
|
|||||||
from ..assemblicon.context import AdvancedContext, FdContext
|
from ..assemblicon.context import AdvancedContext, FdContext
|
||||||
from ..assemblicon.artproc import (
|
from ..assemblicon.artproc import (
|
||||||
anchor_to_pos,
|
anchor_to_pos,
|
||||||
|
align_paste,
|
||||||
align_alpha_composite,
|
align_alpha_composite,
|
||||||
VerticalAnchor,
|
VerticalAnchor,
|
||||||
HorizontalAnchor,
|
HorizontalAnchor,
|
||||||
@@ -10,6 +11,7 @@ from ..assemblicon.artproc import (
|
|||||||
|
|
||||||
def build_action_icons(ctx: AdvancedContext) -> None:
|
def build_action_icons(ctx: AdvancedContext) -> None:
|
||||||
_build_image_properties_icon(ctx)
|
_build_image_properties_icon(ctx)
|
||||||
|
_build_image_zoom_origin_icon(ctx)
|
||||||
|
|
||||||
|
|
||||||
def _build_image_properties_icon(ctx: AdvancedContext) -> None:
|
def _build_image_properties_icon(ctx: AdvancedContext) -> None:
|
||||||
@@ -27,3 +29,59 @@ def _build_image_properties_icon(ctx: AdvancedContext) -> None:
|
|||||||
|
|
||||||
# save artifact
|
# save artifact
|
||||||
ctx.save_fd_artifact(art, FdContext.Actions, "image-properties")
|
ctx.save_fd_artifact(art, FdContext.Actions, "image-properties")
|
||||||
|
|
||||||
|
|
||||||
|
def _build_image_zoom_origin_icon(ctx: AdvancedContext) -> None:
|
||||||
|
# load triangle assets
|
||||||
|
triangle_left = ctx.load_temporary_artifact("triangle-left.png").resize(
|
||||||
|
(300, 300), PIL.Image.Resampling.LANCZOS
|
||||||
|
)
|
||||||
|
triangle_down = ctx.load_temporary_artifact("triangle-down.png").resize(
|
||||||
|
(300, 300), PIL.Image.Resampling.LANCZOS
|
||||||
|
)
|
||||||
|
triangle_right = ctx.load_temporary_artifact("triangle-right.png").resize(
|
||||||
|
(300, 300), PIL.Image.Resampling.LANCZOS
|
||||||
|
)
|
||||||
|
triangle_up = ctx.load_temporary_artifact("triangle-up.png").resize(
|
||||||
|
(300, 300), PIL.Image.Resampling.LANCZOS
|
||||||
|
)
|
||||||
|
|
||||||
|
# load inner image
|
||||||
|
inner = ctx.load_temporary_artifact("image-jpeg.png")
|
||||||
|
resized_inner = inner.resize((570, 570), PIL.Image.Resampling.LANCZOS)
|
||||||
|
|
||||||
|
# composite this icon
|
||||||
|
icon = ctx.new_artifact()
|
||||||
|
align_paste(
|
||||||
|
icon,
|
||||||
|
resized_inner,
|
||||||
|
anchor_to_pos(icon, HorizontalAnchor.Center, VerticalAnchor.Center),
|
||||||
|
anchor_to_pos(resized_inner, HorizontalAnchor.Center, VerticalAnchor.Center),
|
||||||
|
)
|
||||||
|
align_alpha_composite(
|
||||||
|
icon,
|
||||||
|
triangle_left,
|
||||||
|
anchor_to_pos(icon, HorizontalAnchor.Left, VerticalAnchor.Center),
|
||||||
|
anchor_to_pos(triangle_left, HorizontalAnchor.Left, VerticalAnchor.Center),
|
||||||
|
)
|
||||||
|
align_alpha_composite(
|
||||||
|
icon,
|
||||||
|
triangle_right,
|
||||||
|
anchor_to_pos(icon, HorizontalAnchor.Right, VerticalAnchor.Center),
|
||||||
|
anchor_to_pos(triangle_right, HorizontalAnchor.Right, VerticalAnchor.Center),
|
||||||
|
)
|
||||||
|
align_alpha_composite(
|
||||||
|
icon,
|
||||||
|
triangle_up,
|
||||||
|
anchor_to_pos(icon, HorizontalAnchor.Center, VerticalAnchor.Top),
|
||||||
|
anchor_to_pos(triangle_up, HorizontalAnchor.Center, VerticalAnchor.Top),
|
||||||
|
)
|
||||||
|
align_alpha_composite(
|
||||||
|
icon,
|
||||||
|
triangle_down,
|
||||||
|
anchor_to_pos(icon, HorizontalAnchor.Center, VerticalAnchor.Bottom),
|
||||||
|
anchor_to_pos(triangle_down, HorizontalAnchor.Center, VerticalAnchor.Bottom),
|
||||||
|
)
|
||||||
|
|
||||||
|
# save it
|
||||||
|
ctx.save_fd_artifact(icon, FdContext.Actions, "image-zoom-original")
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
from ..assemblicon.context import AdvancedContext, FdContext
|
from ..assemblicon.context import AdvancedContext, FdContext
|
||||||
|
from ..assemblicon.utils import Artifact
|
||||||
|
|
||||||
|
|
||||||
def build_action_icons(ctx: AdvancedContext) -> None:
|
def build_action_icons(ctx: AdvancedContext) -> None:
|
||||||
_build_go_icons(ctx)
|
_build_go_icons(ctx)
|
||||||
|
|
||||||
_build_object_flip_icons(ctx)
|
_build_object_flip_icons(ctx)
|
||||||
_build_object_rotate_icons(ctx)
|
_build_object_rotate_icons(ctx)
|
||||||
|
|
||||||
|
_build_zoom_origin_and_fit_best_icons(ctx)
|
||||||
|
_build_zoom_in_out_icons(ctx)
|
||||||
|
|
||||||
|
|
||||||
def _build_go_icons(ctx: AdvancedContext) -> None:
|
def _build_go_icons(ctx: AdvancedContext) -> None:
|
||||||
# build go-* base
|
# build go-* base
|
||||||
@@ -50,3 +55,68 @@ def _build_object_rotate_icons(ctx: AdvancedContext) -> None:
|
|||||||
art = ctx.render_svg_then_load(ctx.input_artifact("object-rotate-right.svg"))
|
art = ctx.render_svg_then_load(ctx.input_artifact("object-rotate-right.svg"))
|
||||||
with art:
|
with art:
|
||||||
ctx.save_fd_artifact(art, FdContext.Actions, "object-rotate-right")
|
ctx.save_fd_artifact(art, FdContext.Actions, "object-rotate-right")
|
||||||
|
|
||||||
|
|
||||||
|
def _build_zoom_origin_and_fit_best_icons(ctx: AdvancedContext) -> None:
|
||||||
|
# load triangle assets
|
||||||
|
triangle = ctx.render_svg_then_load(ctx.input_artifact("component", "triangle.svg"))
|
||||||
|
background = ctx.render_svg_then_load(
|
||||||
|
ctx.input_artifact("component", "background.svg")
|
||||||
|
)
|
||||||
|
|
||||||
|
# create 4 triangle icons for following building
|
||||||
|
triangle_left = ctx.new_artifact()
|
||||||
|
triangle_left.paste(background, (0, 0), triangle)
|
||||||
|
triangle = triangle.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
|
triangle_down = ctx.new_artifact()
|
||||||
|
triangle_down.paste(background, (0, 0), triangle)
|
||||||
|
triangle = triangle.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
|
triangle_right = ctx.new_artifact()
|
||||||
|
triangle_right.paste(background, (0, 0), triangle)
|
||||||
|
triangle = triangle.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
|
triangle_up = ctx.new_artifact()
|
||||||
|
triangle_up.paste(background, (0, 0), triangle)
|
||||||
|
|
||||||
|
# save them for reuse
|
||||||
|
ctx.save_temporary_artifact(triangle_left, "triangle-left.png")
|
||||||
|
ctx.save_temporary_artifact(triangle_down, "triangle-down.png")
|
||||||
|
ctx.save_temporary_artifact(triangle_right, "triangle-right.png")
|
||||||
|
ctx.save_temporary_artifact(triangle_up, "triangle-up.png")
|
||||||
|
|
||||||
|
# build icons
|
||||||
|
with triangle_left, triangle_down, triangle_right, triangle_up:
|
||||||
|
_build_zoom_origin_icon(
|
||||||
|
ctx, triangle_left, triangle_down, triangle_right, triangle_up
|
||||||
|
)
|
||||||
|
_build_zoom_fit_best_icon(
|
||||||
|
ctx, triangle_left, triangle_down, triangle_right, triangle_up
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _build_zoom_origin_icon(
|
||||||
|
ctx: AdvancedContext,
|
||||||
|
triangle_left: Artifact,
|
||||||
|
triangle_down: Artifact,
|
||||||
|
triangle_right: Artifact,
|
||||||
|
triangle_up: Artifact,
|
||||||
|
) -> None:
|
||||||
|
# TODO: finihs this in future
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def _build_zoom_fit_best_icon(
|
||||||
|
ctx: AdvancedContext,
|
||||||
|
triangle_left: Artifact,
|
||||||
|
triangle_down: Artifact,
|
||||||
|
triangle_right: Artifact,
|
||||||
|
triangle_up: Artifact,
|
||||||
|
) -> None:
|
||||||
|
# TODO: finihs this in future
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def _build_zoom_in_out_icons(ctx: AdvancedContext) -> None:
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user