wrend/textures/
texture_create_context_js.rs1use crate::{IntoJsWrapper, TextureCreateContext};
2use std::ops::{Deref, DerefMut};
3use wasm_bindgen::prelude::wasm_bindgen;
4use web_sys::{HtmlCanvasElement, WebGl2RenderingContext};
5
6pub type TextureCreateContextJsInner = TextureCreateContext;
7
8#[wasm_bindgen(inspectable, js_name = TextureCreateContext)]
9pub struct TextureCreateContextJs(TextureCreateContextJsInner);
10
11#[wasm_bindgen(js_class = TextureCreateContext)]
12impl TextureCreateContextJs {
13 pub fn gl(&self) -> WebGl2RenderingContext {
14 self.deref().gl().to_owned()
15 }
16
17 pub fn now(&self) -> f64 {
18 self.deref().now()
19 }
20
21 pub fn canvas(&self) -> HtmlCanvasElement {
22 self.deref().canvas().clone()
23 }
24}
25
26impl TextureCreateContextJs {
27 pub fn into_inner(self) -> TextureCreateContextJsInner {
28 self.0
29 }
30}
31
32impl Deref for TextureCreateContextJs {
33 type Target = TextureCreateContextJsInner;
34
35 fn deref(&self) -> &Self::Target {
36 &self.0
37 }
38}
39
40impl DerefMut for TextureCreateContextJs {
41 fn deref_mut(&mut self) -> &mut TextureCreateContextJsInner {
42 &mut self.0
43 }
44}
45
46impl From<TextureCreateContext> for TextureCreateContextJs {
47 fn from(attribute_create_context: TextureCreateContext) -> Self {
48 TextureCreateContextJs(attribute_create_context)
49 }
50}
51
52impl IntoJsWrapper for TextureCreateContext {
53 type Result = TextureCreateContextJs;
54
55 fn into_js_wrapper(self) -> Self::Result {
56 self.into()
57 }
58}
59
60impl From<&TextureCreateContext> for TextureCreateContextJs {
61 fn from(attribute_create_context: &TextureCreateContext) -> Self {
62 TextureCreateContextJs(attribute_create_context.to_owned())
63 }
64}
65
66impl IntoJsWrapper for &TextureCreateContext {
67 type Result = TextureCreateContextJs;
68
69 fn into_js_wrapper(self) -> Self::Result {
70 self.into()
71 }
72}