diff options
Diffstat (limited to 'src/platform/graphics/web_canvas/Geometry.cpp')
-rw-r--r-- | src/platform/graphics/web_canvas/Geometry.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/platform/graphics/web_canvas/Geometry.cpp b/src/platform/graphics/web_canvas/Geometry.cpp index 0f2f5a16..42669d88 100644 --- a/src/platform/graphics/web_canvas/Geometry.cpp +++ b/src/platform/graphics/web_canvas/Geometry.cpp @@ -1,14 +1,37 @@ +#include <memory> #include "cru/platform/graphics/web_canvas/WebCanvasGeometry.h" #include "cru/platform/graphics/web_canvas/WebCanvasGraphicsFactory.h" +#include "cru/platform/graphics/web_canvas/WebCanvasMatrix.h" #include "cru/platform/graphics/web_canvas/WebCanvasResource.h" #include "cru/platform/web/Js.h" namespace cru::platform::graphics::web_canvas { -bool WebCanvasGeometry::StrokeContains(float width, const Point& point) {} +WebCanvasGeometry::WebCanvasGeometry(WebCanvasGraphicsFactory* factory, + emscripten::val canvas, + emscripten::val path2d) + : WebCanvasResource(factory), + canvas_(std::move(canvas)), + path2d_(std::move(path2d)) {} + +WebCanvasGeometry::~WebCanvasGeometry() {} + +std::unique_ptr<IGeometry> WebCanvasGeometry::Transform(const Matrix& matrix) { + auto new_path = web::js::Construct("Path2D"); + auto js_matrix = CreateDomMatrix(matrix); + new_path.call<void>("addPath", js_matrix); + return std::make_unique<WebCanvasGeometry>(GetFactory(), canvas_, + std::move(new_path)); +} WebCanvasGeometryBuilder::WebCanvasGeometryBuilder( - WebCanvasGraphicsFactory* factory) - : WebCanvasResource(factory) {} + WebCanvasGraphicsFactory* factory, emscripten::val canvas) + : WebCanvasResource(factory), canvas_(std::move(canvas)) {} WebCanvasGeometryBuilder::~WebCanvasGeometryBuilder() {} + +std::unique_ptr<IGeometry> WebCanvasGeometryBuilder::Build() { + auto new_path = web::js::Construct("Path2D", GetPathData()); + return std::make_unique<WebCanvasGeometry>(GetFactory(), canvas_, + std::move(new_path)); +} } // namespace cru::platform::graphics::web_canvas |