diff options
author | crupest <crupest@outlook.com> | 2023-10-09 22:25:54 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-09 22:25:54 +0800 |
commit | 78760fd8a5b310ca4e8de502e510b95c9b4c880c (patch) | |
tree | d53da9e28decf583d027cc8eb023c591e02ee73f /src/platform/graphics/web_canvas/WebCanvasRef.cpp | |
parent | 1907d4fffd24e6d6bd1b7db7d903da60e53888dc (diff) | |
download | cru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.tar.gz cru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.tar.bz2 cru-78760fd8a5b310ca4e8de502e510b95c9b4c880c.zip |
...
Diffstat (limited to 'src/platform/graphics/web_canvas/WebCanvasRef.cpp')
-rw-r--r-- | src/platform/graphics/web_canvas/WebCanvasRef.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/platform/graphics/web_canvas/WebCanvasRef.cpp b/src/platform/graphics/web_canvas/WebCanvasRef.cpp new file mode 100644 index 00000000..c4f75626 --- /dev/null +++ b/src/platform/graphics/web_canvas/WebCanvasRef.cpp @@ -0,0 +1,16 @@ +#include "cru/platform/graphics/web_canvas/WebCanvasRef.h" +#include "cru/platform/web/JsUtility.h" + +#include <cassert> +#include <utility> + +namespace cru::platform::graphics::web_canvas { +WebCanvasRef::WebCanvasRef(emscripten::val canvas_val) + : val_(std::move(canvas_val)) { + assert(web::IsNotNullAndInstanceOf(val_, "HTMLCanvasElement")); +} + +int WebCanvasRef::GetWidth() const { return val_["width"].as<int>(); } + +int WebCanvasRef::GetHeight() const { return val_["height"].as<int>(); } +} // namespace cru::platform::graphics::web_canvas |