aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graphics/web_canvas
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-10-12 21:44:26 +0800
committercrupest <crupest@outlook.com>2023-10-12 21:44:26 +0800
commit2025756fab9103a3baa8999445e61628cfb9b392 (patch)
treef076e51fb4580e77c50579743128176ba4c0e86c /include/cru/platform/graphics/web_canvas
parent3c5aa6583d7ab2533ff721282d1efd52d07281c7 (diff)
downloadcru-2025756fab9103a3baa8999445e61628cfb9b392.tar.gz
cru-2025756fab9103a3baa8999445e61628cfb9b392.tar.bz2
cru-2025756fab9103a3baa8999445e61628cfb9b392.zip
...
Diffstat (limited to 'include/cru/platform/graphics/web_canvas')
-rw-r--r--include/cru/platform/graphics/web_canvas/WebCanvasGeometry.h20
-rw-r--r--include/cru/platform/graphics/web_canvas/WebCanvasMatrix.h9
-rw-r--r--include/cru/platform/graphics/web_canvas/WebCanvasRef.h3
3 files changed, 27 insertions, 5 deletions
diff --git a/include/cru/platform/graphics/web_canvas/WebCanvasGeometry.h b/include/cru/platform/graphics/web_canvas/WebCanvasGeometry.h
index dfb5bbe7..5aca42d1 100644
--- a/include/cru/platform/graphics/web_canvas/WebCanvasGeometry.h
+++ b/include/cru/platform/graphics/web_canvas/WebCanvasGeometry.h
@@ -10,14 +10,20 @@
namespace cru::platform::graphics::web_canvas {
class WebCanvasGeometry : public WebCanvasResource, public virtual IGeometry {
public:
- WebCanvasGeometry(WebCanvasGraphicsFactory* factory, emscripten::val path2d);
+ WebCanvasGeometry(WebCanvasGraphicsFactory* factory, emscripten::val canvas,
+ emscripten::val path2d);
~WebCanvasGeometry() override;
bool StrokeContains(float width, const Point& point) override;
- virtual bool FillContains(const Point& point) = 0;
- virtual Rect GetBounds() = 0;
- virtual std::unique_ptr<IGeometry> Transform(const Matrix& matrix) = 0;
+
+ bool FillContains(const Point& point) override;
+
+ Rect GetBounds() override;
+
+ std::unique_ptr<IGeometry> Transform(const Matrix& matrix) override;
+
private:
+ emscripten::val canvas_;
emscripten::val path2d_;
};
@@ -27,10 +33,14 @@ class WebCanvasGeometry : public WebCanvasResource, public virtual IGeometry {
class WebCanvasGeometryBuilder : public WebCanvasResource,
public SvgGeometryBuilderMixin {
public:
- WebCanvasGeometryBuilder(WebCanvasGraphicsFactory* factory);
+ WebCanvasGeometryBuilder(WebCanvasGraphicsFactory* factory,
+ emscripten::val canvas);
~WebCanvasGeometryBuilder() override;
std::unique_ptr<IGeometry> Build() override;
+
+ private:
+ emscripten::val canvas_;
};
} // namespace cru::platform::graphics::web_canvas
diff --git a/include/cru/platform/graphics/web_canvas/WebCanvasMatrix.h b/include/cru/platform/graphics/web_canvas/WebCanvasMatrix.h
new file mode 100644
index 00000000..428e0ae5
--- /dev/null
+++ b/include/cru/platform/graphics/web_canvas/WebCanvasMatrix.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "../../Matrix.h"
+
+#include <emscripten/val.h>
+
+namespace cru::platform::graphics::web_canvas {
+emscripten::val CreateDomMatrix(const Matrix& matrix);
+}
diff --git a/include/cru/platform/graphics/web_canvas/WebCanvasRef.h b/include/cru/platform/graphics/web_canvas/WebCanvasRef.h
index 4cb960bd..a5d4f395 100644
--- a/include/cru/platform/graphics/web_canvas/WebCanvasRef.h
+++ b/include/cru/platform/graphics/web_canvas/WebCanvasRef.h
@@ -18,6 +18,9 @@ namespace cru::platform::graphics::web_canvas {
int GetWidth() const;
int GetHeight() const;
+ void Save() const;
+ void Restore() const;
+
private:
emscripten::val val_;
};