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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#[allow(unused_imports)]
use crate::*;
extern "C" {
    fn path2d_add_path(instance: DOMReference, add_path: DOMReference, add_path: DOMReference);
}

pub fn add_path(instance: DOMReference, path: DOMReference, transformation: DOMReference) {
    unsafe { path2d_add_path(instance, path, transformation) }
}
extern "C" {
    fn path2d_close_path(instance: DOMReference);
}

pub fn close_path(instance: DOMReference) {
    unsafe { path2d_close_path(instance) }
}
extern "C" {
    fn path2d_move_to(instance: DOMReference, move_to: f32, move_to: f32);
}

pub fn move_to(instance: DOMReference, x: f32, y: f32) {
    unsafe { path2d_move_to(instance, x, y) }
}
extern "C" {
    fn path2d_line_to(instance: DOMReference, line_to: f32, line_to: f32);
}

pub fn line_to(instance: DOMReference, x: f32, y: f32) {
    unsafe { path2d_line_to(instance, x, y) }
}
extern "C" {
    fn path2d_quadratic_curve_to(
        instance: DOMReference,
        quadratic_curve_to: f32,
        quadratic_curve_to: f32,
        quadratic_curve_to: f32,
        quadratic_curve_to: f32,
    );
}

pub fn quadratic_curve_to(instance: DOMReference, cpx: f32, cpy: f32, x: f32, y: f32) {
    unsafe { path2d_quadratic_curve_to(instance, cpx, cpy, x, y) }
}
extern "C" {
    fn path2d_bezier_curve_to(
        instance: DOMReference,
        bezier_curve_to: f32,
        bezier_curve_to: f32,
        bezier_curve_to: f32,
        bezier_curve_to: f32,
        bezier_curve_to: f32,
        bezier_curve_to: f32,
    );
}

pub fn bezier_curve_to(
    instance: DOMReference,
    cp1x: f32,
    cp1y: f32,
    cp2x: f32,
    cp2y: f32,
    x: f32,
    y: f32,
) {
    unsafe { path2d_bezier_curve_to(instance, cp1x, cp1y, cp2x, cp2y, x, y) }
}
extern "C" {
    fn path2d_arc_to(
        instance: DOMReference,
        arc_to: f32,
        arc_to: f32,
        arc_to: f32,
        arc_to: f32,
        arc_to: f32,
    );
}

pub fn arc_to(instance: DOMReference, x1: f32, y1: f32, x2: f32, y2: f32, radius: f32) {
    unsafe { path2d_arc_to(instance, x1, y1, x2, y2, radius) }
}
extern "C" {
    fn path2d_rect(instance: DOMReference, rect: f32, rect: f32, rect: f32, rect: f32);
}

pub fn rect(instance: DOMReference, x: f32, y: f32, w: f32, h: f32) {
    unsafe { path2d_rect(instance, x, y, w, h) }
}
extern "C" {
    fn path2d_arc(
        instance: DOMReference,
        arc: f32,
        arc: f32,
        arc: f32,
        arc: f32,
        arc: f32,
        arc: i32,
    );
}

pub fn arc(
    instance: DOMReference,
    x: f32,
    y: f32,
    radius: f32,
    start_angle: f32,
    end_angle: f32,
    anticlockwise: bool,
) {
    unsafe {
        path2d_arc(
            instance,
            x,
            y,
            radius,
            start_angle,
            end_angle,
            if anticlockwise { 1 } else { 0 },
        )
    }
}
extern "C" {
    fn path2d_ellipse(
        instance: DOMReference,
        ellipse: f32,
        ellipse: f32,
        ellipse: f32,
        ellipse: f32,
        ellipse: f32,
        ellipse: f32,
        ellipse: f32,
        ellipse: i32,
    );
}

pub fn ellipse(
    instance: DOMReference,
    x: f32,
    y: f32,
    radius_x: f32,
    radius_y: f32,
    rotation: f32,
    start_angle: f32,
    end_angle: f32,
    anticlockwise: bool,
) {
    unsafe {
        path2d_ellipse(
            instance,
            x,
            y,
            radius_x,
            radius_y,
            rotation,
            start_angle,
            end_angle,
            if anticlockwise { 1 } else { 0 },
        )
    }
}