nsvg 0.5.1

A simple SVG parser and rasterizer using NanoSVG
Documentation
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/* automatically generated by rust-bindgen */

#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        fmt.write_str("__BindgenUnionField")
    }
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGpaintType {
    NSVG_PAINT_NONE = 0,
    NSVG_PAINT_COLOR = 1,
    NSVG_PAINT_LINEAR_GRADIENT = 2,
    NSVG_PAINT_RADIAL_GRADIENT = 3,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGspreadType {
    NSVG_SPREAD_PAD = 0,
    NSVG_SPREAD_REFLECT = 1,
    NSVG_SPREAD_REPEAT = 2,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGlineJoin {
    NSVG_JOIN_MITER = 0,
    NSVG_JOIN_ROUND = 1,
    NSVG_JOIN_BEVEL = 2,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGlineCap {
    NSVG_CAP_BUTT = 0,
    NSVG_CAP_ROUND = 1,
    NSVG_CAP_SQUARE = 2,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGfillRule {
    NSVG_FILLRULE_NONZERO = 0,
    NSVG_FILLRULE_EVENODD = 1,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NSVGflags { NSVG_FLAGS_VISIBLE = 1, }
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGgradientStop {
    pub color: ::std::os::raw::c_uint,
    pub offset: f32,
}
#[test]
fn bindgen_test_layout_NSVGgradientStop() {
    assert_eq!(::std::mem::size_of::<NSVGgradientStop>() , 8usize , concat ! (
               "Size of: " , stringify ! ( NSVGgradientStop ) ));
    assert_eq! (::std::mem::align_of::<NSVGgradientStop>() , 4usize , concat !
                ( "Alignment of " , stringify ! ( NSVGgradientStop ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradientStop ) ) . color as * const _
                as usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradientStop ) ,
                "::" , stringify ! ( color ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradientStop ) ) . offset as * const
                _ as usize } , 4usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradientStop ) ,
                "::" , stringify ! ( offset ) ));
}
impl Clone for NSVGgradientStop {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGgradient {
    pub xform: [f32; 6usize],
    pub spread: ::std::os::raw::c_char,
    pub fx: f32,
    pub fy: f32,
    pub nstops: ::std::os::raw::c_int,
    pub stops: [NSVGgradientStop; 1usize],
}
#[test]
fn bindgen_test_layout_NSVGgradient() {
    assert_eq!(::std::mem::size_of::<NSVGgradient>() , 48usize , concat ! (
               "Size of: " , stringify ! ( NSVGgradient ) ));
    assert_eq! (::std::mem::align_of::<NSVGgradient>() , 4usize , concat ! (
                "Alignment of " , stringify ! ( NSVGgradient ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . xform as * const _ as
                usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( xform ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . spread as * const _ as
                usize } , 24usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( spread ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . fx as * const _ as
                usize } , 28usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( fx ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . fy as * const _ as
                usize } , 32usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( fy ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . nstops as * const _ as
                usize } , 36usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( nstops ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGgradient ) ) . stops as * const _ as
                usize } , 40usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGgradient ) , "::" ,
                stringify ! ( stops ) ));
}
impl Clone for NSVGgradient {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGpaint {
    pub type_: ::std::os::raw::c_char,
    pub __bindgen_anon_1: NSVGpaint__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGpaint__bindgen_ty_1 {
    pub color: __BindgenUnionField<::std::os::raw::c_uint>,
    pub gradient: __BindgenUnionField<*mut NSVGgradient>,
    pub bindgen_union_field: u64,
}
#[test]
fn bindgen_test_layout_NSVGpaint__bindgen_ty_1() {
    assert_eq!(::std::mem::size_of::<NSVGpaint__bindgen_ty_1>() , 8usize ,
               concat ! (
               "Size of: " , stringify ! ( NSVGpaint__bindgen_ty_1 ) ));
    assert_eq! (::std::mem::align_of::<NSVGpaint__bindgen_ty_1>() , 8usize ,
                concat ! (
                "Alignment of " , stringify ! ( NSVGpaint__bindgen_ty_1 ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpaint__bindgen_ty_1 ) ) . color as *
                const _ as usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpaint__bindgen_ty_1
                ) , "::" , stringify ! ( color ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpaint__bindgen_ty_1 ) ) . gradient as
                * const _ as usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpaint__bindgen_ty_1
                ) , "::" , stringify ! ( gradient ) ));
}
impl Clone for NSVGpaint__bindgen_ty_1 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_NSVGpaint() {
    assert_eq!(::std::mem::size_of::<NSVGpaint>() , 16usize , concat ! (
               "Size of: " , stringify ! ( NSVGpaint ) ));
    assert_eq! (::std::mem::align_of::<NSVGpaint>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( NSVGpaint ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpaint ) ) . type_ as * const _ as
                usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpaint ) , "::" ,
                stringify ! ( type_ ) ));
}
impl Clone for NSVGpaint {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGpath {
    pub pts: *mut f32,
    pub npts: ::std::os::raw::c_int,
    pub closed: ::std::os::raw::c_char,
    pub bounds: [f32; 4usize],
    pub next: *mut NSVGpath,
}
#[test]
fn bindgen_test_layout_NSVGpath() {
    assert_eq!(::std::mem::size_of::<NSVGpath>() , 40usize , concat ! (
               "Size of: " , stringify ! ( NSVGpath ) ));
    assert_eq! (::std::mem::align_of::<NSVGpath>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( NSVGpath ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpath ) ) . pts as * const _ as usize
                } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpath ) , "::" ,
                stringify ! ( pts ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpath ) ) . npts as * const _ as usize
                } , 8usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpath ) , "::" ,
                stringify ! ( npts ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpath ) ) . closed as * const _ as
                usize } , 12usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpath ) , "::" ,
                stringify ! ( closed ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpath ) ) . bounds as * const _ as
                usize } , 16usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpath ) , "::" ,
                stringify ! ( bounds ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGpath ) ) . next as * const _ as usize
                } , 32usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGpath ) , "::" ,
                stringify ! ( next ) ));
}
impl Clone for NSVGpath {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
pub struct NSVGshape {
    pub id: [::std::os::raw::c_char; 64usize],
    pub fill: NSVGpaint,
    pub stroke: NSVGpaint,
    pub opacity: f32,
    pub strokeWidth: f32,
    pub strokeDashOffset: f32,
    pub strokeDashArray: [f32; 8usize],
    pub strokeDashCount: ::std::os::raw::c_char,
    pub strokeLineJoin: ::std::os::raw::c_char,
    pub strokeLineCap: ::std::os::raw::c_char,
    pub miterLimit: f32,
    pub fillRule: ::std::os::raw::c_char,
    pub flags: ::std::os::raw::c_uchar,
    pub bounds: [f32; 4usize],
    pub paths: *mut NSVGpath,
    pub next: *mut NSVGshape,
}
#[test]
fn bindgen_test_layout_NSVGshape() {
    assert_eq!(::std::mem::size_of::<NSVGshape>() , 184usize , concat ! (
               "Size of: " , stringify ! ( NSVGshape ) ));
    assert_eq! (::std::mem::align_of::<NSVGshape>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( NSVGshape ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . id as * const _ as usize
                } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( id ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . fill as * const _ as
                usize } , 64usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( fill ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . stroke as * const _ as
                usize } , 80usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( stroke ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . opacity as * const _ as
                usize } , 96usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( opacity ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeWidth as * const _
                as usize } , 100usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeWidth ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeDashOffset as *
                const _ as usize } , 104usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeDashOffset ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeDashArray as *
                const _ as usize } , 108usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeDashArray ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeDashCount as *
                const _ as usize } , 140usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeDashCount ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeLineJoin as * const
                _ as usize } , 141usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeLineJoin ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . strokeLineCap as * const
                _ as usize } , 142usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( strokeLineCap ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . miterLimit as * const _
                as usize } , 144usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( miterLimit ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . fillRule as * const _ as
                usize } , 148usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( fillRule ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . flags as * const _ as
                usize } , 149usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( flags ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . bounds as * const _ as
                usize } , 152usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( bounds ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . paths as * const _ as
                usize } , 168usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( paths ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGshape ) ) . next as * const _ as
                usize } , 176usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGshape ) , "::" ,
                stringify ! ( next ) ));
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct NSVGimage {
    pub width: f32,
    pub height: f32,
    pub shapes: *mut NSVGshape,
}
#[test]
fn bindgen_test_layout_NSVGimage() {
    assert_eq!(::std::mem::size_of::<NSVGimage>() , 16usize , concat ! (
               "Size of: " , stringify ! ( NSVGimage ) ));
    assert_eq! (::std::mem::align_of::<NSVGimage>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( NSVGimage ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGimage ) ) . width as * const _ as
                usize } , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGimage ) , "::" ,
                stringify ! ( width ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGimage ) ) . height as * const _ as
                usize } , 4usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGimage ) , "::" ,
                stringify ! ( height ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const NSVGimage ) ) . shapes as * const _ as
                usize } , 8usize , concat ! (
                "Alignment of field: " , stringify ! ( NSVGimage ) , "::" ,
                stringify ! ( shapes ) ));
}
impl Clone for NSVGimage {
    fn clone(&self) -> Self { *self }
}
extern "C" {
    pub fn nsvgParseFromFile(filename: *const ::std::os::raw::c_char,
                             units: *const ::std::os::raw::c_char, dpi: f32)
     -> *mut NSVGimage;
}
extern "C" {
    pub fn nsvgParse(input: *mut ::std::os::raw::c_char,
                     units: *const ::std::os::raw::c_char, dpi: f32)
     -> *mut NSVGimage;
}
extern "C" {
    pub fn nsvgDelete(image: *mut NSVGimage);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NSVGrasterizer {
    _unused: [u8; 0],
}
extern "C" {
    pub fn nsvgCreateRasterizer() -> *mut NSVGrasterizer;
}
extern "C" {
    pub fn nsvgRasterize(r: *mut NSVGrasterizer, image: *mut NSVGimage,
                         tx: f32, ty: f32, scale: f32,
                         dst: *mut ::std::os::raw::c_uchar,
                         w: ::std::os::raw::c_int, h: ::std::os::raw::c_int,
                         stride: ::std::os::raw::c_int);
}
extern "C" {
    pub fn nsvgDeleteRasterizer(arg1: *mut NSVGrasterizer);
}