use js_sys::Object;
use wasm_bindgen::prelude::*;
use crate::{create_object_with_properties, renderer::Renderer};
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Renderer)]
#[derive(Debug, Clone)]
pub type Canvas;
#[wasm_bindgen(js_namespace = L, js_name = canvas)]
pub fn canvas_with_options(options: &CanvasOptions) -> Canvas;
#[wasm_bindgen(js_namespace = L, js_name = canvas)]
pub fn canvas() -> Canvas;
}
create_object_with_properties!(
(CanvasOptions, CanvasOptions),
(padding, padding, f64),
(tolerance, tolerance, f64),
(stroke, stroke, bool),
(color, color, String),
(weight, weight, f64),
(opacity, opacity, f64),
(line_cap, lineCap, String),
(line_join, lineJoin, String),
(dash_array, dashArray, String),
(dash_offset, dashOffset, String),
(fill, fill, bool),
(fill_color, fillColor, String),
(fill_opacity, fillOpacity, f64),
(fill_rule, fillRule, String),
(interactive, interactive, bool),
(bubbling_mouse_events, bubblingMouseEvents, bool),
(class_name, className, String),
(pane, pane, String)
);
impl Default for CanvasOptions {
fn default() -> Self {
CanvasOptions::new()
}
}
impl Canvas {
#[must_use]
pub fn new() -> Self {
canvas()
}
#[must_use]
pub fn with_options(options: &CanvasOptions) -> Self {
canvas_with_options(options)
}
}
impl Default for Canvas {
fn default() -> Self {
Self::new()
}
}