@@ -114,6 +114,10 @@ pub struct LineDash {
114
114
pub offset : f64 ,
115
115
}
116
116
117
+ fn pdf_coord__equal ( p1 : & pdf_coord , p2 : & pdf_coord ) -> bool {
118
+ ( ( p1. x - p2. x ) . abs ( ) < 1e-7 ) && ( ( p1. y - p2. y ) . abs ( ) < 1e-7 )
119
+ }
120
+
117
121
unsafe extern "C" fn inversematrix ( mut W : & mut pdf_tmatrix , mut M : & pdf_tmatrix ) -> i32 {
118
122
let mut det: f64 = 0. ;
119
123
det = M . a * M . d - M . b * M . c ;
@@ -283,21 +287,21 @@ unsafe extern "C" fn pdf_path__next_pe<'a>(
283
287
pe. p [ 0 ] = * cp;
284
288
}
285
289
PeType :: LINETO => {
286
- if & pe. p [ 0 ] != cp {
290
+ if ! pdf_coord__equal ( & pe. p [ 0 ] , cp ) {
287
291
let mut pe = pa_elem:: default ( ) ;
288
292
pe. p [ 0 ] = * cp;
289
293
pa. path . push ( pe) ;
290
294
}
291
295
}
292
296
PeType :: CURVETO => {
293
- if & pe. p [ 2 ] != cp {
297
+ if ! pdf_coord__equal ( & pe. p [ 2 ] , cp ) {
294
298
let mut pe = pa_elem:: default ( ) ;
295
299
pe. p [ 0 ] = * cp;
296
300
pa. path . push ( pe) ;
297
301
}
298
302
}
299
303
PeType :: CURVETO_Y | PeType :: CURVETO_V => {
300
- if & pe. p [ 1 ] != cp {
304
+ if ! pdf_coord__equal ( & pe. p [ 1 ] , cp ) {
301
305
let mut pe = pa_elem:: default ( ) ;
302
306
pe. p [ 0 ] = * cp;
303
307
pa. path . push ( pe) ;
@@ -358,12 +362,12 @@ unsafe extern "C" fn pdf_path__curveto(
358
362
p2 : & pdf_coord ,
359
363
) -> i32 {
360
364
let pe = pdf_path__next_pe ( pa, cp) ;
361
- if cp == p0 {
365
+ if pdf_coord__equal ( cp , p0 ) {
362
366
pe. typ = PeType :: CURVETO_V ;
363
367
pe. p [ 0 ] = * p1;
364
368
* cp = * p2;
365
369
pe. p [ 1 ] = * cp;
366
- } else if p1 == p2 {
370
+ } else if pdf_coord__equal ( p1 , p2 ) {
367
371
pe. typ = PeType :: CURVETO_Y ;
368
372
pe. p [ 0 ] = * p0;
369
373
* cp = * p1;
@@ -449,7 +453,7 @@ unsafe extern "C" fn pdf_path__elliptarc(
449
453
p0. y += ca. y ;
450
454
if pa. path . is_empty ( ) {
451
455
pdf_path__moveto ( pa, cp, & mut p0) ;
452
- } else if cp != & p0 {
456
+ } else if ! pdf_coord__equal ( cp , & p0) {
453
457
pdf_path__lineto ( pa, cp, & mut p0) ;
454
458
/* add line seg */
455
459
}
@@ -823,8 +827,8 @@ impl pdf_gstate {
823
827
strokecolor : pdf_color_graycolor_new ( 0. ) . unwrap ( ) ,
824
828
fillcolor : pdf_color_graycolor_new ( 0. ) . unwrap ( ) ,
825
829
linedash : LineDash :: default ( ) ,
826
- linecap : 0 ,
827
- linejoin : 0 ,
830
+ linecap : 0 , // TODO make enum
831
+ linejoin : 0 , // TODO make enum
828
832
linewidth : 1. ,
829
833
miterlimit : 10. ,
830
834
flatness : 1 ,
0 commit comments