mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
js: DOM API. Part 1 (#12296)
This commit is contained in:
parent
0ff23eeb74
commit
cfecb62299
17 changed files with 1032 additions and 2 deletions
40
vlib/jsdom/html_canvas_element.js.v
Normal file
40
vlib/jsdom/html_canvas_element.js.v
Normal file
|
@ -0,0 +1,40 @@
|
|||
module jsdom
|
||||
|
||||
import jsdom.ctx
|
||||
|
||||
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) ctx.ContextResult {
|
||||
mut res := ctx.NoneContext{}
|
||||
#let ctx = elem.node.getContext(ctx_.str);
|
||||
#if (ctx instanceof CanvasRenderingContext2D) { res = new jsdom__ctx__CanvasRenderingContext2D(ctx); res.ctx = ctx; }
|
||||
|
||||
return res
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue