v/vlib/jsdom/html_canvas_element.js.v

39 lines
870 B
V
Raw Normal View History

2021-10-27 22:18:09 +02:00
module jsdom
pub struct HTMLCanvasElement {
HTMLElement
}
pub fn (cv HTMLCanvasElement) height() int {
ret := 0
#ret.val = cv.node.height;
return ret
}
pub fn (cv HTMLCanvasElement) width() int {
ret := 0
#ret.val = cv.node.width;
return ret
}
pub fn (cv HTMLCanvasElement) typ() NodeType {
return .element
}
pub fn (elem HTMLCanvasElement) add_event_listener(event string, cb EventCallback) {
#elem.node.addEventListener(event.str, function (event) { let e = jsdom__dispatch_event_target(this);
#let ev = jsdom__dispatch_event(event); ev.event = event;
#return cb(e,ev)
#});
}
pub fn (elem HTMLCanvasElement) get_context(ctx_ string) ContextResult {
mut res := NoneContext{}
2021-10-27 22:18:09 +02:00
#let ctx = elem.node.getContext(ctx_.str);
#if (ctx instanceof CanvasRenderingContext2D) { res = new jsdom__CanvasRenderingContext2D(ctx); res.ctx = ctx; }
2021-10-27 22:18:09 +02:00
return res
}