1extern "C" {
10 fn nvg_save();
11 fn nvg_restore();
12 fn nvg_reset();
13 fn nvg__create_image(w: i32, h: i32, filename: i64, image_flags: i32) -> i32;
14 fn nvg_create_font(name: i64) -> i32;
15 fn nvg_text_bounds(x: f32, y: f32, text: i64, bounds: i64) -> f32;
16 fn nvg_text_box_bounds(x: f32, y: f32, break_row_width: f32, text: i64) -> i64;
17 fn nvg_text(x: f32, y: f32, text: i64) -> f32;
18 fn nvg_text_box(x: f32, y: f32, break_row_width: f32, text: i64);
19 fn nvg_stroke_color(color: i32);
20 fn nvg_stroke_paint(paint: i64);
21 fn nvg_fill_color(color: i32);
22 fn nvg_fill_paint(paint: i64);
23 fn nvg_miter_limit(limit: f32);
24 fn nvg_stroke_width(size: f32);
25 fn nvg__line_cap(cap: i32);
26 fn nvg__line_join(join: i32);
27 fn nvg_global_alpha(alpha: f32);
28 fn nvg_reset_transform();
29 fn nvg_apply_transform(node: i64);
30 fn nvg_translate(x: f32, y: f32);
31 fn nvg_rotate(angle: f32);
32 fn nvg_skew_x(angle: f32);
33 fn nvg_skew_y(angle: f32);
34 fn nvg_scale(x: f32, y: f32);
35 fn nvg_image_size(image: i32) -> i64;
36 fn nvg_delete_image(image: i32);
37 fn nvg_linear_gradient(sx: f32, sy: f32, ex: f32, ey: f32, icol: i32, ocol: i32) -> i64;
38 fn nvg_box_gradient(x: f32, y: f32, w: f32, h: f32, r: f32, f: f32, icol: i32, ocol: i32) -> i64;
39 fn nvg_radial_gradient(cx: f32, cy: f32, inr: f32, outr: f32, icol: i32, ocol: i32) -> i64;
40 fn nvg_image_pattern(ox: f32, oy: f32, ex: f32, ey: f32, angle: f32, image: i32, alpha: f32) -> i64;
41 fn nvg_scissor(x: f32, y: f32, w: f32, h: f32);
42 fn nvg_intersect_scissor(x: f32, y: f32, w: f32, h: f32);
43 fn nvg_reset_scissor();
44 fn nvg_begin_path();
45 fn nvg_move_to(x: f32, y: f32);
46 fn nvg_line_to(x: f32, y: f32);
47 fn nvg_bezier_to(c_1x: f32, c_1y: f32, c_2x: f32, c_2y: f32, x: f32, y: f32);
48 fn nvg_quad_to(cx: f32, cy: f32, x: f32, y: f32);
49 fn nvg_arc_to(x_1: f32, y_1: f32, x_2: f32, y_2: f32, radius: f32);
50 fn nvg_close_path();
51 fn nvg__path_winding(dir: i32);
52 fn nvg__arc(cx: f32, cy: f32, r: f32, a_0: f32, a_1: f32, dir: i32);
53 fn nvg_rect(x: f32, y: f32, w: f32, h: f32);
54 fn nvg_rounded_rect(x: f32, y: f32, w: f32, h: f32, r: f32);
55 fn nvg_rounded_rect_varying(x: f32, y: f32, w: f32, h: f32, rad_top_left: f32, rad_top_right: f32, rad_bottom_right: f32, rad_bottom_left: f32);
56 fn nvg_ellipse(cx: f32, cy: f32, rx: f32, ry: f32);
57 fn nvg_circle(cx: f32, cy: f32, r: f32);
58 fn nvg_fill();
59 fn nvg_stroke();
60 fn nvg_find_font(name: i64) -> i32;
61 fn nvg_add_fallback_font_id(base_font: i32, fallback_font: i32) -> i32;
62 fn nvg_add_fallback_font(base_font: i64, fallback_font: i64) -> i32;
63 fn nvg_font_size(size: f32);
64 fn nvg_font_blur(blur: f32);
65 fn nvg_text_letter_spacing(spacing: f32);
66 fn nvg_text_line_height(line_height: f32);
67 fn nvg__text_align(h_align: i32, v_align: i32);
68 fn nvg_font_face_id(font: i32);
69 fn nvg_font_face(font: i64);
70 fn nvg_dora_ssr();
71 fn nvg_get_dora_ssr(scale: f32) -> i64;
72}
73pub struct Nvg { }
74impl Nvg {
75 pub fn save() {
76 unsafe { nvg_save(); }
77 }
78 pub fn restore() {
79 unsafe { nvg_restore(); }
80 }
81 pub fn reset() {
82 unsafe { nvg_reset(); }
83 }
84 pub(crate) fn _create_image(w: i32, h: i32, filename: &str, image_flags: i32) -> i32 {
85 unsafe { return nvg__create_image(w, h, crate::dora::from_string(filename), image_flags); }
86 }
87 pub fn create_font(name: &str) -> i32 {
88 unsafe { return nvg_create_font(crate::dora::from_string(name)); }
89 }
90 pub fn text_bounds(x: f32, y: f32, text: &str, bounds: &crate::dora::Rect) -> f32 {
91 unsafe { return nvg_text_bounds(x, y, crate::dora::from_string(text), bounds.raw()); }
92 }
93 pub fn text_box_bounds(x: f32, y: f32, break_row_width: f32, text: &str) -> crate::dora::Rect {
94 unsafe { return crate::dora::Rect::from(nvg_text_box_bounds(x, y, break_row_width, crate::dora::from_string(text))); }
95 }
96 pub fn text(x: f32, y: f32, text: &str) -> f32 {
97 unsafe { return nvg_text(x, y, crate::dora::from_string(text)); }
98 }
99 pub fn text_box(x: f32, y: f32, break_row_width: f32, text: &str) {
100 unsafe { nvg_text_box(x, y, break_row_width, crate::dora::from_string(text)); }
101 }
102 pub fn stroke_color(color: &crate::dora::Color) {
103 unsafe { nvg_stroke_color(color.to_argb() as i32); }
104 }
105 pub fn stroke_paint(paint: &crate::dora::VGPaint) {
106 unsafe { nvg_stroke_paint(paint.raw()); }
107 }
108 pub fn fill_color(color: &crate::dora::Color) {
109 unsafe { nvg_fill_color(color.to_argb() as i32); }
110 }
111 pub fn fill_paint(paint: &crate::dora::VGPaint) {
112 unsafe { nvg_fill_paint(paint.raw()); }
113 }
114 pub fn miter_limit(limit: f32) {
115 unsafe { nvg_miter_limit(limit); }
116 }
117 pub fn stroke_width(size: f32) {
118 unsafe { nvg_stroke_width(size); }
119 }
120 pub(crate) fn _line_cap(cap: i32) {
121 unsafe { nvg__line_cap(cap); }
122 }
123 pub(crate) fn _line_join(join: i32) {
124 unsafe { nvg__line_join(join); }
125 }
126 pub fn global_alpha(alpha: f32) {
127 unsafe { nvg_global_alpha(alpha); }
128 }
129 pub fn reset_transform() {
130 unsafe { nvg_reset_transform(); }
131 }
132 pub fn apply_transform(node: &dyn crate::dora::INode) {
133 unsafe { nvg_apply_transform(node.raw()); }
134 }
135 pub fn translate(x: f32, y: f32) {
136 unsafe { nvg_translate(x, y); }
137 }
138 pub fn rotate(angle: f32) {
139 unsafe { nvg_rotate(angle); }
140 }
141 pub fn skew_x(angle: f32) {
142 unsafe { nvg_skew_x(angle); }
143 }
144 pub fn skew_y(angle: f32) {
145 unsafe { nvg_skew_y(angle); }
146 }
147 pub fn scale(x: f32, y: f32) {
148 unsafe { nvg_scale(x, y); }
149 }
150 pub fn image_size(image: i32) -> crate::dora::Size {
151 unsafe { return crate::dora::Size::from(nvg_image_size(image)); }
152 }
153 pub fn delete_image(image: i32) {
154 unsafe { nvg_delete_image(image); }
155 }
156 pub fn linear_gradient(sx: f32, sy: f32, ex: f32, ey: f32, icol: &crate::dora::Color, ocol: &crate::dora::Color) -> crate::dora::VGPaint {
157 unsafe { return crate::dora::VGPaint::from(nvg_linear_gradient(sx, sy, ex, ey, icol.to_argb() as i32, ocol.to_argb() as i32)); }
158 }
159 pub fn box_gradient(x: f32, y: f32, w: f32, h: f32, r: f32, f: f32, icol: &crate::dora::Color, ocol: &crate::dora::Color) -> crate::dora::VGPaint {
160 unsafe { return crate::dora::VGPaint::from(nvg_box_gradient(x, y, w, h, r, f, icol.to_argb() as i32, ocol.to_argb() as i32)); }
161 }
162 pub fn radial_gradient(cx: f32, cy: f32, inr: f32, outr: f32, icol: &crate::dora::Color, ocol: &crate::dora::Color) -> crate::dora::VGPaint {
163 unsafe { return crate::dora::VGPaint::from(nvg_radial_gradient(cx, cy, inr, outr, icol.to_argb() as i32, ocol.to_argb() as i32)); }
164 }
165 pub fn image_pattern(ox: f32, oy: f32, ex: f32, ey: f32, angle: f32, image: i32, alpha: f32) -> crate::dora::VGPaint {
166 unsafe { return crate::dora::VGPaint::from(nvg_image_pattern(ox, oy, ex, ey, angle, image, alpha)); }
167 }
168 pub fn scissor(x: f32, y: f32, w: f32, h: f32) {
169 unsafe { nvg_scissor(x, y, w, h); }
170 }
171 pub fn intersect_scissor(x: f32, y: f32, w: f32, h: f32) {
172 unsafe { nvg_intersect_scissor(x, y, w, h); }
173 }
174 pub fn reset_scissor() {
175 unsafe { nvg_reset_scissor(); }
176 }
177 pub fn begin_path() {
178 unsafe { nvg_begin_path(); }
179 }
180 pub fn move_to(x: f32, y: f32) {
181 unsafe { nvg_move_to(x, y); }
182 }
183 pub fn line_to(x: f32, y: f32) {
184 unsafe { nvg_line_to(x, y); }
185 }
186 pub fn bezier_to(c_1x: f32, c_1y: f32, c_2x: f32, c_2y: f32, x: f32, y: f32) {
187 unsafe { nvg_bezier_to(c_1x, c_1y, c_2x, c_2y, x, y); }
188 }
189 pub fn quad_to(cx: f32, cy: f32, x: f32, y: f32) {
190 unsafe { nvg_quad_to(cx, cy, x, y); }
191 }
192 pub fn arc_to(x_1: f32, y_1: f32, x_2: f32, y_2: f32, radius: f32) {
193 unsafe { nvg_arc_to(x_1, y_1, x_2, y_2, radius); }
194 }
195 pub fn close_path() {
196 unsafe { nvg_close_path(); }
197 }
198 pub(crate) fn _path_winding(dir: i32) {
199 unsafe { nvg__path_winding(dir); }
200 }
201 pub(crate) fn _arc(cx: f32, cy: f32, r: f32, a_0: f32, a_1: f32, dir: i32) {
202 unsafe { nvg__arc(cx, cy, r, a_0, a_1, dir); }
203 }
204 pub fn rect(x: f32, y: f32, w: f32, h: f32) {
205 unsafe { nvg_rect(x, y, w, h); }
206 }
207 pub fn rounded_rect(x: f32, y: f32, w: f32, h: f32, r: f32) {
208 unsafe { nvg_rounded_rect(x, y, w, h, r); }
209 }
210 pub fn rounded_rect_varying(x: f32, y: f32, w: f32, h: f32, rad_top_left: f32, rad_top_right: f32, rad_bottom_right: f32, rad_bottom_left: f32) {
211 unsafe { nvg_rounded_rect_varying(x, y, w, h, rad_top_left, rad_top_right, rad_bottom_right, rad_bottom_left); }
212 }
213 pub fn ellipse(cx: f32, cy: f32, rx: f32, ry: f32) {
214 unsafe { nvg_ellipse(cx, cy, rx, ry); }
215 }
216 pub fn circle(cx: f32, cy: f32, r: f32) {
217 unsafe { nvg_circle(cx, cy, r); }
218 }
219 pub fn fill() {
220 unsafe { nvg_fill(); }
221 }
222 pub fn stroke() {
223 unsafe { nvg_stroke(); }
224 }
225 pub fn find_font(name: &str) -> i32 {
226 unsafe { return nvg_find_font(crate::dora::from_string(name)); }
227 }
228 pub fn add_fallback_font_id(base_font: i32, fallback_font: i32) -> i32 {
229 unsafe { return nvg_add_fallback_font_id(base_font, fallback_font); }
230 }
231 pub fn add_fallback_font(base_font: &str, fallback_font: &str) -> i32 {
232 unsafe { return nvg_add_fallback_font(crate::dora::from_string(base_font), crate::dora::from_string(fallback_font)); }
233 }
234 pub fn font_size(size: f32) {
235 unsafe { nvg_font_size(size); }
236 }
237 pub fn font_blur(blur: f32) {
238 unsafe { nvg_font_blur(blur); }
239 }
240 pub fn text_letter_spacing(spacing: f32) {
241 unsafe { nvg_text_letter_spacing(spacing); }
242 }
243 pub fn text_line_height(line_height: f32) {
244 unsafe { nvg_text_line_height(line_height); }
245 }
246 pub(crate) fn _text_align(h_align: i32, v_align: i32) {
247 unsafe { nvg__text_align(h_align, v_align); }
248 }
249 pub fn font_face_id(font: i32) {
250 unsafe { nvg_font_face_id(font); }
251 }
252 pub fn font_face(font: &str) {
253 unsafe { nvg_font_face(crate::dora::from_string(font)); }
254 }
255 pub fn dora_ssr() {
256 unsafe { nvg_dora_ssr(); }
257 }
258 pub fn get_dora_ssr(scale: f32) -> crate::dora::Texture2D {
259 unsafe { return crate::dora::Texture2D::from(nvg_get_dora_ssr(scale)).unwrap(); }
260 }
261}