feat: refactor (3/3) finish user side adaption
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext
|
from ..assemblicon.highlevel.utils import FdContext, VART_HW
|
||||||
from ..assemblicon.highlevel.utils import VART_HW
|
from ..assemblicon.highlevel.source import TempArtSource, NewArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import FdArtSink
|
||||||
from ..assemblicon.geometry import Rectangle
|
from ..assemblicon.geometry import Rectangle
|
||||||
from ..assemblicon.lowlevel.artproc import (
|
from ..assemblicon.lowlevel.artproc import (
|
||||||
art_anchor_to_offset,
|
art_anchor_to_offset,
|
||||||
@@ -16,20 +17,37 @@ from ..assemblicon.lowlevel.artproc import (
|
|||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"nostd/action/image-properties",
|
"nostd/action/image-properties",
|
||||||
("nostd/mimetype/image-jpeg", "std/status/dialog-infomation"),
|
(
|
||||||
|
TempArtSource("image-jpeg.png"),
|
||||||
|
TempArtSource("dialog-infomation.png"),
|
||||||
|
FdArtSink(FdContext.Actions, "image-properties"),
|
||||||
|
),
|
||||||
build_image_properties_icon,
|
build_image_properties_icon,
|
||||||
)
|
)
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"nostd/action/image-zoom-original",
|
"nostd/action/image-zoom-original",
|
||||||
("nostd/mimetype/image-jpeg", "component/triangles"),
|
(
|
||||||
|
TempArtSource("component", "triangle-left.png"),
|
||||||
|
TempArtSource("component", "triangle-down.png"),
|
||||||
|
TempArtSource("component", "triangle-right.png"),
|
||||||
|
TempArtSource("component", "triangle-up.png"),
|
||||||
|
TempArtSource("image-jpeg.png"),
|
||||||
|
NewArtSource(),
|
||||||
|
FdArtSink(FdContext.Actions, "image-zoom-original"),
|
||||||
|
),
|
||||||
build_image_zoom_original_icon,
|
build_image_zoom_original_icon,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_image_properties_icon(env: AuroraEnvironment) -> None:
|
def build_image_properties_icon(
|
||||||
art = env.load_temporary_artifact("image-jpeg.png")
|
env: AuroraEnvironment,
|
||||||
|
jpeg_src: TempArtSource,
|
||||||
|
infomation_src: TempArtSource,
|
||||||
|
fd_sink: FdArtSink,
|
||||||
|
) -> None:
|
||||||
|
art = jpeg_src.pull(env)
|
||||||
|
|
||||||
info_mark = env.load_temporary_artifact("dialog-infomation.png")
|
info_mark = infomation_src.pull(env)
|
||||||
resized_info_mark = default_art_resize(info_mark, 500, 500)
|
resized_info_mark = default_art_resize(info_mark, 500, 500)
|
||||||
|
|
||||||
align_alpha_composite(
|
align_alpha_composite(
|
||||||
@@ -42,31 +60,32 @@ def build_image_properties_icon(env: AuroraEnvironment) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# save artifact
|
# save artifact
|
||||||
env.save_fd_artifact(art, FdContext.Actions, "image-properties")
|
fd_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
def build_image_zoom_original_icon(env: AuroraEnvironment) -> None:
|
def build_image_zoom_original_icon(
|
||||||
|
env: AuroraEnvironment,
|
||||||
|
tri_left_src: TempArtSource,
|
||||||
|
tri_down_src: TempArtSource,
|
||||||
|
tri_right_src: TempArtSource,
|
||||||
|
tri_up_src: TempArtSource,
|
||||||
|
inner_src: TempArtSource,
|
||||||
|
new_art: NewArtSource,
|
||||||
|
fd_sink: FdArtSink,
|
||||||
|
) -> None:
|
||||||
# load triangle assets
|
# load triangle assets
|
||||||
TRI_SIZE = (200, 200)
|
TRI_SIZE = (200, 200)
|
||||||
tri_left = default_art_resize(
|
tri_left = default_art_resize(tri_left_src.pull(env), *TRI_SIZE)
|
||||||
env.load_temporary_artifact("component", "triangle-left.png"), *TRI_SIZE
|
tri_down = default_art_resize(tri_down_src.pull(env), *TRI_SIZE)
|
||||||
)
|
tri_right = default_art_resize(tri_right_src.pull(env), *TRI_SIZE)
|
||||||
tri_down = default_art_resize(
|
tri_up = default_art_resize(tri_up_src.pull(env), *TRI_SIZE)
|
||||||
env.load_temporary_artifact("component", "triangle-down.png"), *TRI_SIZE
|
|
||||||
)
|
|
||||||
tri_right = default_art_resize(
|
|
||||||
env.load_temporary_artifact("component", "triangle-right.png"), *TRI_SIZE
|
|
||||||
)
|
|
||||||
tri_up = default_art_resize(
|
|
||||||
env.load_temporary_artifact("component", "triangle-up.png"), *TRI_SIZE
|
|
||||||
)
|
|
||||||
|
|
||||||
# load inner image
|
# load inner image
|
||||||
inner = env.load_temporary_artifact("image-jpeg.png")
|
inner = inner_src.pull(env)
|
||||||
resized_inner = default_art_resize(inner, 680, 680)
|
resized_inner = default_art_resize(inner, 680, 680)
|
||||||
|
|
||||||
# composite this icon
|
# composite this icon
|
||||||
icon = env.new_artifact()
|
icon = new_art.pull()
|
||||||
|
|
||||||
align_paste(
|
align_paste(
|
||||||
icon,
|
icon,
|
||||||
@@ -125,4 +144,4 @@ def build_image_zoom_original_icon(env: AuroraEnvironment) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# save it
|
# save it
|
||||||
env.save_fd_artifact(icon, FdContext.Actions, "image-zoom-original")
|
fd_sink.push(env, icon)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import PIL.Image
|
|
||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext, WinCategory, MacCategory
|
from ..assemblicon.highlevel.utils import FdContext, WinCategory, MacCategory
|
||||||
|
from ..assemblicon.highlevel.source import SvgSource, TempArtSource, NewArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import FdArtSink, WinArtSink, MacArtSink
|
||||||
from ..assemblicon.lowlevel.artproc import (
|
from ..assemblicon.lowlevel.artproc import (
|
||||||
art_anchor_to_offset,
|
art_anchor_to_offset,
|
||||||
default_art_resize,
|
default_art_resize,
|
||||||
@@ -13,18 +14,31 @@ from ..assemblicon.lowlevel.artproc import (
|
|||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"nostd/application/org.sarasachipworkshop.picture",
|
"nostd/application/org.sarasachipworkshop.picture",
|
||||||
("nostd/mimetype/image-jpeg", ),
|
(
|
||||||
|
SvgSource("app", "sarasacw-picture", "app-frame.svg"),
|
||||||
|
TempArtSource("image-jpeg.png"),
|
||||||
|
NewArtSource(),
|
||||||
|
FdArtSink(FdContext.Applications, "org.sarasachipworkshop.picture"),
|
||||||
|
WinArtSink(WinCategory.Application, "sarasacw-picture"),
|
||||||
|
MacArtSink(MacCategory.Application, "sarasacw-picture"),
|
||||||
|
),
|
||||||
build_sarasacw_picture_icons,
|
build_sarasacw_picture_icons,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_sarasacw_picture_icons(env: AuroraEnvironment) -> None:
|
def build_sarasacw_picture_icons(
|
||||||
app = env.new_artifact()
|
env: AuroraEnvironment,
|
||||||
frame = env.render_svg_then_load(
|
frame_src: SvgSource,
|
||||||
env.input_artifact("app", "sarasacw-picture", "app-frame.svg")
|
inner_src: TempArtSource,
|
||||||
)
|
new_art: NewArtSource,
|
||||||
|
fd_sink: FdArtSink,
|
||||||
|
win_sink: WinArtSink,
|
||||||
|
mac_sink: MacArtSink,
|
||||||
|
) -> None:
|
||||||
|
app = new_art.pull()
|
||||||
|
frame = frame_src.pull(env)
|
||||||
|
|
||||||
inner = env.load_temporary_artifact("image-jpeg.png")
|
inner = inner_src.pull(env)
|
||||||
resized_inner = default_art_resize(inner, 990, 990)
|
resized_inner = default_art_resize(inner, 990, 990)
|
||||||
|
|
||||||
align_paste(
|
align_paste(
|
||||||
@@ -38,6 +52,6 @@ def build_sarasacw_picture_icons(env: AuroraEnvironment) -> None:
|
|||||||
app.alpha_composite(frame, (0, 0))
|
app.alpha_composite(frame, (0, 0))
|
||||||
|
|
||||||
# save artifact
|
# save artifact
|
||||||
env.save_fd_artifact(app, FdContext.Applications, "org.sarasachipworkshop.picture")
|
fd_sink.push(env, app)
|
||||||
env.save_win_artifact(app, WinCategory.Application, "sarasacw-picture")
|
win_sink.push(env, app)
|
||||||
env.save_mac_artifact(app, MacCategory.Application, "sarasacw-picture")
|
mac_sink.push(env, app)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
import PIL.ImageEnhance
|
import PIL.ImageEnhance
|
||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext, WinCategory, MacCategory
|
from ..assemblicon.highlevel.utils import FdContext, WinCategory, MacCategory
|
||||||
from ..assemblicon.highlevel.utils import Artifact
|
from ..assemblicon.highlevel.source import SvgSource, BitmapSource, TempArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import TempArtSink, FdArtSink, WinArtSink, MacArtSink
|
||||||
from ..assemblicon.geometry import Rectangle, Point
|
from ..assemblicon.geometry import Rectangle, Point
|
||||||
from ..assemblicon.lowlevel.artproc import (
|
from ..assemblicon.lowlevel.artproc import (
|
||||||
aspect_ratio_scale_and_crop,
|
aspect_ratio_scale_and_crop,
|
||||||
@@ -12,28 +13,49 @@ from ..assemblicon.lowlevel.artproc import (
|
|||||||
|
|
||||||
|
|
||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register("component/image-base", (), build_image_base_icon)
|
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"nostd/mimetype/image-jpeg", ("component/image-base",), build_image_jpeg_icon
|
"component/image-base",
|
||||||
|
(
|
||||||
|
SvgSource("component", "image-base.svg"),
|
||||||
|
TempArtSink("component", "image-base.png"),
|
||||||
|
),
|
||||||
|
build_image_base_icon,
|
||||||
|
)
|
||||||
|
ctx.register(
|
||||||
|
"nostd/mimetype/image-jpeg",
|
||||||
|
(
|
||||||
|
TempArtSource("component", "image-base.png"),
|
||||||
|
BitmapSource("ext", "bitmap", "Niinsaare_järv.jpg"),
|
||||||
|
TempArtSink("image-jpeg.png"),
|
||||||
|
FdArtSink(FdContext.MimeTypes, "image-jpeg"),
|
||||||
|
WinArtSink(WinCategory.Extension, "jpg"),
|
||||||
|
MacArtSink(MacCategory.Extension, "jpg"),
|
||||||
|
),
|
||||||
|
build_image_jpeg_icon,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
IMAGE_INNER_RECT = Rectangle(Point(20 * 4, 52 * 4), Point(236 * 4, 204 * 4))
|
IMAGE_INNER_RECT = Rectangle(Point(20 * 4, 52 * 4), Point(236 * 4, 204 * 4))
|
||||||
|
|
||||||
|
|
||||||
def build_image_base_icon(env: AuroraEnvironment) -> None:
|
def build_image_base_icon(
|
||||||
env.render_svg(
|
env: AuroraEnvironment, src: SvgSource, sink: TempArtSink
|
||||||
env.input_artifact("component", "image-base.svg"),
|
) -> None:
|
||||||
env.__temporary_artifact("component", "image-base.png"),
|
src.pull_to_temp(env, sink)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def build_image_jpeg_icon(env: AuroraEnvironment) -> None:
|
def build_image_jpeg_icon(
|
||||||
jpg_image = env.load_temporary_artifact("component", "image-base.png")
|
env: AuroraEnvironment,
|
||||||
|
base_src: TempArtSource,
|
||||||
|
bitmap_src: BitmapSource,
|
||||||
|
temp_sink: TempArtSink,
|
||||||
|
fd_sink: FdArtSink,
|
||||||
|
win_sink: WinArtSink,
|
||||||
|
mac_sink: MacArtSink,
|
||||||
|
) -> None:
|
||||||
|
jpg_image = base_src.pull(env)
|
||||||
|
|
||||||
jpg_image_inner = env.load_input_bitmap_artifact(
|
jpg_image_inner = bitmap_src.pull(env)
|
||||||
"ext", "bitmap", "Niinsaare_järv.jpg"
|
|
||||||
)
|
|
||||||
with jpg_image_inner:
|
with jpg_image_inner:
|
||||||
# crop the area which is interested by ourselves
|
# crop the area which is interested by ourselves
|
||||||
interest_area = Rectangle.from_pos_size_rect(Point(2700, 0), 5016, 3888)
|
interest_area = Rectangle.from_pos_size_rect(Point(2700, 0), 5016, 3888)
|
||||||
@@ -60,9 +82,9 @@ def build_image_jpeg_icon(env: AuroraEnvironment) -> None:
|
|||||||
|
|
||||||
# build artifacts
|
# build artifacts
|
||||||
# save as temporary for future use
|
# save as temporary for future use
|
||||||
env.save_temporary_artifact(jpg_image, "image-jpeg.png")
|
temp_sink.push(env, jpg_image)
|
||||||
# save for FD
|
# save for FD
|
||||||
env.save_fd_artifact(jpg_image, FdContext.MimeTypes, "image-jpeg")
|
fd_sink.push(env, jpg_image)
|
||||||
# save for windows and mac
|
# save for windows and mac
|
||||||
env.save_win_artifact(jpg_image, WinCategory.Extension, "jpg")
|
win_sink.push(env, jpg_image)
|
||||||
env.save_mac_artifact(jpg_image, MacCategory.Extension, "jpg")
|
mac_sink.push(env, jpg_image)
|
||||||
|
|||||||
@@ -1,101 +1,142 @@
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext
|
from ..assemblicon.highlevel.utils import FdContext
|
||||||
from ..assemblicon.highlevel.utils import Artifact
|
from ..assemblicon.highlevel.source import SvgSource, TempArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import FdArtSink
|
||||||
|
|
||||||
|
|
||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register("std/action/go-[previous|down|next|up]", (), build_go_icons)
|
ctx.register(
|
||||||
|
"std/action/go-[previous|down|next|up]",
|
||||||
|
(
|
||||||
|
SvgSource("component", "go-base.svg"),
|
||||||
|
SvgSource("component", "go-inner-shining.svg"),
|
||||||
|
SvgSource("component", "go-inner.svg"),
|
||||||
|
FdArtSink(FdContext.Actions, "go-previous"),
|
||||||
|
FdArtSink(FdContext.Actions, "go-down"),
|
||||||
|
FdArtSink(FdContext.Actions, "go-next"),
|
||||||
|
FdArtSink(FdContext.Actions, "go-up"),
|
||||||
|
),
|
||||||
|
build_go_icons,
|
||||||
|
)
|
||||||
|
|
||||||
ctx.register("std/action/object-flip-*", (), build_object_flip_icons)
|
ctx.register(
|
||||||
ctx.register("std/action/object-rotate-*", (), build_object_rotate_icons)
|
"std/action/object-flip-*",
|
||||||
|
(
|
||||||
|
SvgSource("object-flip-horizontal.svg"),
|
||||||
|
SvgSource("object-flip-vertical.svg"),
|
||||||
|
FdArtSink(FdContext.Actions, "object-flip-horizontal"),
|
||||||
|
FdArtSink(FdContext.Actions, "object-flip-vertical"),
|
||||||
|
),
|
||||||
|
build_object_flip_icons,
|
||||||
|
)
|
||||||
|
ctx.register(
|
||||||
|
"std/action/object-rotate-*",
|
||||||
|
(
|
||||||
|
SvgSource("object-rotate-left.svg"),
|
||||||
|
SvgSource("object-rotate-right.svg"),
|
||||||
|
FdArtSink(FdContext.Actions, "object-rotate-left"),
|
||||||
|
FdArtSink(FdContext.Actions, "object-rotate-right"),
|
||||||
|
),
|
||||||
|
build_object_rotate_icons,
|
||||||
|
)
|
||||||
|
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"std/action/zoom-[original|fit-best]",
|
"std/action/zoom-[original|fit-best]",
|
||||||
("component/triangles",),
|
(
|
||||||
|
TempArtSource("component", "triangle-left.png"),
|
||||||
|
TempArtSource("component", "triangle-down.png"),
|
||||||
|
TempArtSource("component", "triangle-right.png"),
|
||||||
|
TempArtSource("component", "triangle-up.png"),
|
||||||
|
FdArtSink(FdContext.Actions, "zoom-original"),
|
||||||
|
FdArtSink(FdContext.Actions, "zoom-fit-best"),
|
||||||
|
),
|
||||||
build_zoom_origin_and_fit_best_icons,
|
build_zoom_origin_and_fit_best_icons,
|
||||||
)
|
)
|
||||||
ctx.register("std/action/zoom-[in|out]", (), build_zoom_in_out_icons)
|
ctx.register(
|
||||||
|
"std/action/zoom-[in|out]",
|
||||||
|
(
|
||||||
|
FdArtSink(FdContext.Actions, "zoom-in"),
|
||||||
|
FdArtSink(FdContext.Actions, "zoom-out"),
|
||||||
|
),
|
||||||
|
build_zoom_in_out_icons,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_go_icons(env: AuroraEnvironment) -> None:
|
def build_go_icons(
|
||||||
# build go-* base
|
env: AuroraEnvironment,
|
||||||
go_base = env.render_svg_then_load(env.input_artifact("component", "go-base.svg"))
|
base_src: SvgSource,
|
||||||
# build go-* shining
|
shining_src: SvgSource,
|
||||||
go_inner_shining = env.render_svg_then_load(
|
inner_src: SvgSource,
|
||||||
env.input_artifact("component", "go-inner-shining.svg"),
|
sink_previous: FdArtSink,
|
||||||
)
|
sink_down: FdArtSink,
|
||||||
# build go-* inner
|
sink_next: FdArtSink,
|
||||||
go_inner = env.render_svg_then_load(
|
sink_up: FdArtSink,
|
||||||
env.input_artifact("component", "go-inner.svg"),
|
) -> None:
|
||||||
)
|
# build go-* base, shining and inner
|
||||||
|
go_base = base_src.pull(env)
|
||||||
|
go_inner_shining = shining_src.pull(env)
|
||||||
|
go_inner = inner_src.pull(env)
|
||||||
|
|
||||||
with go_base, go_inner_shining, go_inner:
|
with go_base, go_inner_shining, go_inner:
|
||||||
go_mask = go_inner
|
go_mask = go_inner
|
||||||
for part in ("previous", "down", "next", "up"):
|
for sink in (sink_previous, sink_down, sink_next, sink_up):
|
||||||
go = go_base.copy()
|
go = go_base.copy()
|
||||||
# render shining with inner mask
|
# render shining with inner mask
|
||||||
go.paste(go_inner_shining, (0, 0), go_mask)
|
go.paste(go_inner_shining, (0, 0), go_mask)
|
||||||
|
|
||||||
# save as FD action
|
# save as FD action
|
||||||
env.save_fd_artifact(go, FdContext.Actions, f"go-{part}")
|
sink.push(env, go)
|
||||||
|
|
||||||
# rotate it for next calling
|
# rotate it for next calling
|
||||||
go_mask = go_mask.transpose(PIL.Image.Transpose.ROTATE_90)
|
go_mask = go_mask.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
|
|
||||||
def build_object_flip_icons(env: AuroraEnvironment) -> None:
|
def build_object_flip_icons(
|
||||||
art = env.render_svg_then_load(env.input_artifact("object-flip-horizontal.svg"))
|
|
||||||
with art:
|
|
||||||
env.save_fd_artifact(art, FdContext.Actions, "object-flip-horizontal")
|
|
||||||
art = env.render_svg_then_load(env.input_artifact("object-flip-vertical.svg"))
|
|
||||||
with art:
|
|
||||||
env.save_fd_artifact(art, FdContext.Actions, "object-flip-vertical")
|
|
||||||
|
|
||||||
|
|
||||||
def build_object_rotate_icons(env: AuroraEnvironment) -> None:
|
|
||||||
art = env.render_svg_then_load(env.input_artifact("object-rotate-left.svg"))
|
|
||||||
with art:
|
|
||||||
env.save_fd_artifact(art, FdContext.Actions, "object-rotate-left")
|
|
||||||
art = env.render_svg_then_load(env.input_artifact("object-rotate-right.svg"))
|
|
||||||
with art:
|
|
||||||
env.save_fd_artifact(art, FdContext.Actions, "object-rotate-right")
|
|
||||||
|
|
||||||
|
|
||||||
def build_zoom_origin_and_fit_best_icons(env: AuroraEnvironment) -> None:
|
|
||||||
# load triangle assets
|
|
||||||
tri_left = env.load_temporary_artifact("component", "triangle-left.png")
|
|
||||||
tri_down = env.load_temporary_artifact("component", "triangle-down.png")
|
|
||||||
tri_right = env.load_temporary_artifact("component", "triangle-right.png")
|
|
||||||
tri_up = env.load_temporary_artifact("component", "triangle-up.png")
|
|
||||||
|
|
||||||
# build icons
|
|
||||||
with tri_left, tri_down, tri_right, tri_up:
|
|
||||||
build_zoom_origin_icon(env, tri_left, tri_down, tri_right, tri_up)
|
|
||||||
build_zoom_fit_best_icon(env, tri_left, tri_down, tri_right, tri_up)
|
|
||||||
|
|
||||||
|
|
||||||
def build_zoom_origin_icon(
|
|
||||||
env: AuroraEnvironment,
|
env: AuroraEnvironment,
|
||||||
tri_left: Artifact,
|
horizontal_src: SvgSource,
|
||||||
tri_down: Artifact,
|
vertical_src: SvgSource,
|
||||||
tri_right: Artifact,
|
horizontal_sink: FdArtSink,
|
||||||
tri_up: Artifact,
|
vertical_sink: FdArtSink,
|
||||||
) -> None:
|
) -> None:
|
||||||
# TODO: finihs this in future
|
art = horizontal_src.pull(env)
|
||||||
pass
|
with art:
|
||||||
|
horizontal_sink.push(env, art)
|
||||||
|
art = vertical_src.pull(env)
|
||||||
|
with art:
|
||||||
|
vertical_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
def build_zoom_fit_best_icon(
|
def build_object_rotate_icons(
|
||||||
env: AuroraEnvironment,
|
env: AuroraEnvironment,
|
||||||
tri_left: Artifact,
|
left_src: SvgSource,
|
||||||
tri_down: Artifact,
|
right_src: SvgSource,
|
||||||
tri_right: Artifact,
|
left_sink: FdArtSink,
|
||||||
tri_up: Artifact,
|
right_sink: FdArtSink,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
art = left_src.pull(env)
|
||||||
|
with art:
|
||||||
|
left_sink.push(env, art)
|
||||||
|
art = right_src.pull(env)
|
||||||
|
with art:
|
||||||
|
right_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
|
def build_zoom_origin_and_fit_best_icons(
|
||||||
|
env: AuroraEnvironment,
|
||||||
|
tri_left_src: TempArtSource,
|
||||||
|
tri_down_src: TempArtSource,
|
||||||
|
tri_right_src: TempArtSource,
|
||||||
|
tri_up_src: TempArtSource,
|
||||||
|
zoom_original_sink: FdArtSink,
|
||||||
|
zoom_fit_best_sink: FdArtSink,
|
||||||
|
) -> None:
|
||||||
|
# TODO: finish this in future
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def build_zoom_in_out_icons(env: AuroraEnvironment) -> None:
|
def build_zoom_in_out_icons(
|
||||||
# TODO: finihs this in future
|
env: AuroraEnvironment, zoom_in_sink: FdArtSink, zoom_out_sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
|
# TODO: finish this in future
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,46 +1,71 @@
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
|
from ..assemblicon.highlevel.source import SvgSource, TempArtSource, NewArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import TempArtSink
|
||||||
|
|
||||||
|
|
||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register("component/generic-background", (), build_generic_background)
|
ctx.register(
|
||||||
|
"component/generic-background",
|
||||||
|
(
|
||||||
|
SvgSource("component", "generic-background.svg"),
|
||||||
|
TempArtSink("component", "generic-background.png"),
|
||||||
|
),
|
||||||
|
build_generic_background,
|
||||||
|
)
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"component/triangles",
|
"component/triangles",
|
||||||
("component/generic-background",),
|
(
|
||||||
|
SvgSource("component", "triangle.svg"),
|
||||||
|
TempArtSource("component", "generic-background.png"),
|
||||||
|
NewArtSource(),
|
||||||
|
TempArtSink("component", "triangle-left.png"),
|
||||||
|
TempArtSink("component", "triangle-down.png"),
|
||||||
|
TempArtSink("component", "triangle-right.png"),
|
||||||
|
TempArtSink("component", "triangle-up.png"),
|
||||||
|
),
|
||||||
build_triangle_icons,
|
build_triangle_icons,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_generic_background(env: AuroraEnvironment) -> None:
|
def build_generic_background(
|
||||||
env.render_svg(
|
env: AuroraEnvironment, src: SvgSource, sink: TempArtSink
|
||||||
env.input_artifact("component", "generic-background.svg"),
|
) -> None:
|
||||||
env.__temporary_artifact("component", "generic-background.png"),
|
src.pull_to_temp(env, sink)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def build_triangle_icons(env: AuroraEnvironment) -> None:
|
def build_triangle_icons(
|
||||||
|
env: AuroraEnvironment,
|
||||||
|
tri_src: SvgSource,
|
||||||
|
bg_src: TempArtSource,
|
||||||
|
new_art: NewArtSource,
|
||||||
|
sink_left: TempArtSink,
|
||||||
|
sink_down: TempArtSink,
|
||||||
|
sink_right: TempArtSink,
|
||||||
|
sink_up: TempArtSink,
|
||||||
|
) -> None:
|
||||||
# load triangle and background assets
|
# load triangle and background assets
|
||||||
tri = env.render_svg_then_load(env.input_artifact("component", "triangle.svg"))
|
tri = tri_src.pull(env)
|
||||||
bg = env.load_temporary_artifact("component", "generic-background.png")
|
bg = bg_src.pull(env)
|
||||||
|
|
||||||
# create 4 triangle icons for following building
|
# create 4 triangle icons for following building
|
||||||
tri_left = env.new_artifact()
|
tri_left = new_art.pull()
|
||||||
tri_left.paste(bg, (0, 0), tri)
|
tri_left.paste(bg, (0, 0), tri)
|
||||||
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
tri_down = env.new_artifact()
|
tri_down = new_art.pull()
|
||||||
tri_down.paste(bg, (0, 0), tri)
|
tri_down.paste(bg, (0, 0), tri)
|
||||||
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
tri_right = env.new_artifact()
|
tri_right = new_art.pull()
|
||||||
tri_right.paste(bg, (0, 0), tri)
|
tri_right.paste(bg, (0, 0), tri)
|
||||||
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
tri = tri.transpose(PIL.Image.Transpose.ROTATE_90)
|
||||||
|
|
||||||
tri_up = env.new_artifact()
|
tri_up = new_art.pull()
|
||||||
tri_up.paste(bg, (0, 0), tri)
|
tri_up.paste(bg, (0, 0), tri)
|
||||||
|
|
||||||
# save them for reuse
|
# save them for reuse
|
||||||
env.save_temporary_artifact(tri_left, "component", "triangle-left.png")
|
sink_left.push(env, tri_left)
|
||||||
env.save_temporary_artifact(tri_down, "component", "triangle-down.png")
|
sink_down.push(env, tri_down)
|
||||||
env.save_temporary_artifact(tri_right, "component", "triangle-right.png")
|
sink_right.push(env, tri_right)
|
||||||
env.save_temporary_artifact(tri_up, "component", "triangle-up.png")
|
sink_up.push(env, tri_up)
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext
|
from ..assemblicon.highlevel.utils import FdContext
|
||||||
|
from ..assemblicon.highlevel.source import FdArtSource
|
||||||
|
from ..assemblicon.highlevel.sink import FdArtSink
|
||||||
|
|
||||||
|
|
||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register(
|
ctx.register(
|
||||||
"std/mimetype/image-x-generic",
|
"std/mimetype/image-x-generic",
|
||||||
("nostd/mimetype/image-jpeg",),
|
(
|
||||||
|
FdArtSource(FdContext.MimeTypes, "image-jpeg"),
|
||||||
|
FdArtSink(FdContext.MimeTypes, "image-x-generic"),
|
||||||
|
),
|
||||||
build_image_x_generic,
|
build_image_x_generic,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_image_x_generic(env: AuroraEnvironment) -> None:
|
def build_image_x_generic(
|
||||||
|
env: AuroraEnvironment, src: FdArtSource, sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
# use image/jpeg as the default image icon
|
# use image/jpeg as the default image icon
|
||||||
env.dup_fd_artifact(
|
src.link_to(env, sink)
|
||||||
FdContext.MimeTypes, "image-jpeg", FdContext.MimeTypes, "image-x-generic"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,51 +1,77 @@
|
|||||||
from ..types import AuroraContext, AuroraEnvironment
|
from ..types import AuroraContext, AuroraEnvironment
|
||||||
from ..assemblicon.highlevel.environment import FdContext
|
from ..assemblicon.highlevel.utils import FdContext
|
||||||
|
from ..assemblicon.highlevel.source import SvgSource
|
||||||
|
from ..assemblicon.highlevel.sink import TempArtSink, FdArtSink
|
||||||
|
|
||||||
|
|
||||||
def register(ctx: AuroraContext) -> None:
|
def register(ctx: AuroraContext) -> None:
|
||||||
ctx.register("std/status/dialog-infomation", (), build_dialog_infomation_icon)
|
ctx.register(
|
||||||
ctx.register("std/status/dialog-warning", (), build_dialog_warning_icon)
|
"std/status/dialog-infomation",
|
||||||
ctx.register("std/status/dialog-error", (), build_dialog_error_icon)
|
(
|
||||||
ctx.register("std/status/dialog-question", (), build_dialog_question_icon)
|
SvgSource("dialog-infomation.svg"),
|
||||||
|
TempArtSink("dialog-infomation.png"),
|
||||||
|
FdArtSink(FdContext.Status, "dialog-infomation"),
|
||||||
def build_dialog_infomation_icon(env: AuroraEnvironment) -> None:
|
),
|
||||||
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
build_dialog_infomation_icon,
|
||||||
art = env.render_svg_then_load(
|
|
||||||
env.input_artifact("dialog-infomation.svg"),
|
|
||||||
env.__temporary_artifact("dialog-infomation.png"),
|
|
||||||
)
|
)
|
||||||
with art:
|
ctx.register(
|
||||||
env.save_fd_artifact(art, FdContext.Status, "dialog-infomation")
|
"std/status/dialog-warning",
|
||||||
|
(
|
||||||
|
SvgSource("dialog-warning.svg"),
|
||||||
def build_dialog_warning_icon(env: AuroraEnvironment) -> None:
|
TempArtSink("dialog-warning.png"),
|
||||||
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
FdArtSink(FdContext.Status, "dialog-warning"),
|
||||||
art = env.render_svg_then_load(
|
),
|
||||||
env.input_artifact("dialog-warning.svg"),
|
build_dialog_warning_icon,
|
||||||
env.__temporary_artifact("dialog-warning.png"),
|
|
||||||
)
|
)
|
||||||
with art:
|
ctx.register(
|
||||||
env.save_fd_artifact(art, FdContext.Status, "dialog-warning")
|
"std/status/dialog-error",
|
||||||
|
(
|
||||||
|
SvgSource("dialog-error.svg"),
|
||||||
def build_dialog_error_icon(env: AuroraEnvironment) -> None:
|
TempArtSink("dialog-error.png"),
|
||||||
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
FdArtSink(FdContext.Status, "dialog-error"),
|
||||||
art = env.render_svg_then_load(
|
),
|
||||||
env.input_artifact("dialog-error.svg"),
|
build_dialog_error_icon,
|
||||||
env.__temporary_artifact("dialog-error.png"),
|
)
|
||||||
|
ctx.register(
|
||||||
|
"std/status/dialog-question",
|
||||||
|
(
|
||||||
|
SvgSource("dialog-question.svg"),
|
||||||
|
TempArtSink("dialog-question.png"),
|
||||||
|
FdArtSink(FdContext.Status, "dialog-question"),
|
||||||
|
),
|
||||||
|
build_dialog_question_icon,
|
||||||
)
|
)
|
||||||
with art:
|
|
||||||
env.save_fd_artifact(art, FdContext.Status, "dialog-error")
|
|
||||||
|
|
||||||
|
|
||||||
def build_dialog_question_icon(env: AuroraEnvironment) -> None:
|
def build_dialog_infomation_icon(
|
||||||
|
env: AuroraEnvironment, src: SvgSource, temp_sink: TempArtSink, fd_sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
|
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
||||||
|
src.pull_to_temp(env, temp_sink)
|
||||||
|
with temp_sink.repull(env) as art:
|
||||||
|
fd_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
|
def build_dialog_warning_icon(
|
||||||
|
env: AuroraEnvironment, src: SvgSource, temp_sink: TempArtSink, fd_sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
|
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
||||||
|
src.pull_to_temp(env, temp_sink)
|
||||||
|
with temp_sink.repull(env) as art:
|
||||||
|
fd_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
|
def build_dialog_error_icon(
|
||||||
|
env: AuroraEnvironment, src: SvgSource, temp_sink: TempArtSink, fd_sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
|
# save dialog icon with FreeDesktop icon and temp icon for reuse.
|
||||||
|
src.pull_to_temp(env, temp_sink)
|
||||||
|
with temp_sink.repull(env) as art:
|
||||||
|
fd_sink.push(env, art)
|
||||||
|
|
||||||
|
|
||||||
|
def build_dialog_question_icon(
|
||||||
|
env: AuroraEnvironment, src: SvgSource, temp_sink: TempArtSink, fd_sink: FdArtSink
|
||||||
|
) -> None:
|
||||||
# TODO: add dialog-question generation
|
# TODO: add dialog-question generation
|
||||||
# # save dialog icon with FreeDesktop icon and temp icon for reuse.
|
|
||||||
# art = env.render_svg_then_load(
|
|
||||||
# env.input_artifact("dialog-question.svg"),
|
|
||||||
# env.temporary_artifact("dialog-question.png"),
|
|
||||||
# )
|
|
||||||
# with art:
|
|
||||||
# env.save_fd_artifact(art, FdContext.Status, "dialog-question")
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user