aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graphics/web_canvas/WebCanvasPainter.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-10-09 22:25:54 +0800
committercrupest <crupest@outlook.com>2023-10-09 22:25:54 +0800
commit78760fd8a5b310ca4e8de502e510b95c9b4c880c (patch)
treed53da9e28decf583d027cc8eb023c591e02ee73f /include/cru/platform/graphics/web_canvas/WebCanvasPainter.h
parent1907d4fffd24e6d6bd1b7db7d903da60e53888dc (diff)
downloadcru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.tar.gz
cru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.tar.bz2
cru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.zip
...
Diffstat (limited to 'include/cru/platform/graphics/web_canvas/WebCanvasPainter.h')
-rw-r--r--include/cru/platform/graphics/web_canvas/WebCanvasPainter.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/cru/platform/graphics/web_canvas/WebCanvasPainter.h b/include/cru/platform/graphics/web_canvas/WebCanvasPainter.h
index cd885aa4..1f7d21b6 100644
--- a/include/cru/platform/graphics/web_canvas/WebCanvasPainter.h
+++ b/include/cru/platform/graphics/web_canvas/WebCanvasPainter.h
@@ -1,11 +1,20 @@
#pragma once
#include "../Painter.h"
+#include "WebCanvasRef.h"
#include "WebCanvasResource.h"
#include <emscripten/val.h>
#include <optional>
namespace cru::platform::graphics::web_canvas {
+/**
+ * Notes about Transform:
+ * Although there is a Matrix object now supported by browsers, it is not
+ * generally available in old browsers. However, now that we are using
+ * WebAssembly, the browsers should be quite up to date, but there is still a
+ * window between the two things. And it is common for a platform to not support
+ * getting transform and only allow you to do transformation.
+ */
class WebCanvasPainter : public WebCanvasResource, public virtual IPainter {
public:
WebCanvasPainter(WebCanvasGraphicsFactory* factory, emscripten::val context,
@@ -17,6 +26,13 @@ class WebCanvasPainter : public WebCanvasResource, public virtual IPainter {
Matrix GetTransform() override;
void SetTransform(const Matrix& transform) override;
+ void ConcatTransform(const Matrix& matrix) override;
+
+ void Clear(const Color& color) override;
+
+ emscripten::val GetCanvas2DContext() const { return context_; }
+ WebCanvasRef GetCanvas();
+
private:
Matrix current_transform_;
emscripten::val context_;