1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::prelude::*;
use js_sys::Object;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Object, typescript_type = "Graphics")]
#[derive(Clone, Debug)]
type Graphics;
#[wasm_bindgen(method, getter)]
fn style(this: &Graphics) -> String;
#[wasm_bindgen(method, setter)]
fn set_style(this: &Graphics, style: &str);
#[wasm_bindgen(method, getter)]
fn linewidth(this: &Graphics) -> f64;
#[wasm_bindgen(method, setter)]
fn set_linewidth(this: &Graphics, linewidth: f64);
#[wasm_bindgen(method)]
fn line(this: &Graphics, pos: Position, end: Position);
#[wasm_bindgen(method)]
fn circle(this: &Graphics, pos: Position, r: f64);
#[wasm_bindgen(method)]
fn rect(this: &Graphics, tl: Position, br: Position);
#[wasm_bindgen]
static graphics: Graphics;
}
#[inline(always)]
pub fn style() -> String {
graphics.style()
}
#[inline(always)]
pub fn set_style(style: &str) {
graphics.set_style(style);
}
#[inline(always)]
pub fn linewidth() -> f64 {
graphics.linewidth()
}
#[inline(always)]
pub fn set_linewidth(linewidth: f64) {
graphics.set_linewidth(linewidth);
}
#[inline(always)]
pub fn line(pos: Position, end: Position) {
graphics.line(pos, end);
}
#[inline(always)]
pub fn circle(pos: Position, r: f64) {
graphics.circle(pos, r);
}
#[inline(always)]
pub fn rect(tl: Position, br: Position) {
graphics.rect(tl, br);
}