add support for loading images as quads

This commit is contained in:
Yeicor
2024-03-03 10:56:44 +01:00
parent c51ddade4b
commit 4c7be17ddc
7 changed files with 178 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ import os
import time
from aiohttp import web
from build123d import Vector
from server import Server
@@ -18,6 +19,7 @@ if 'YACV_DISABLE_SERVER' not in os.environ:
# Expose some nice aliases using the default server instance
show = server.show
show_object = show
show_image = server.show_image
show_all = server.show_cad_all
@@ -26,9 +28,13 @@ def _get_app() -> web.Application:
logging.basicConfig(level=logging.DEBUG)
from logo import build_logo
from build123d import Axis
logo = build_logo(False)
logo = build_logo()
server.show_cad(logo, 'Logo')
server.show_cad(logo.faces().group_by(Axis.X)[0].face().center_location, 'Location')
img_location = logo.faces().group_by(Axis.X)[0].face().center_location # Avoid overlapping:
img_location.position = Vector(img_location.position.X - 1e-2, img_location.position.Y, img_location.position.Z)
server.show_cad(img_location, 'Location')
img_path = os.path.join(os.path.dirname(__file__), '..', 'assets', 'img.jpg')
server.show_image(img_path, img_location, 20)
return server.app