Make UEFI boot-platform build again
[haiku.git] / headers / libs / agg / agg_path_length.h
blob740ba31df2778353d4f61d5221788fe36a09cc8c
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 #ifndef AGG_PATH_LENGTH_INCLUDED
16 #define AGG_PATH_LENGTH_INCLUDED
18 #include "agg_math.h"
20 namespace agg
22 template<class VertexSource>
23 double path_length(VertexSource& vs, unsigned path_id = 0)
25 double len = 0.0;
26 double start_x = 0.0;
27 double start_y = 0.0;
28 double x1 = 0.0;
29 double y1 = 0.0;
30 double x2 = 0.0;
31 double y2 = 0.0;
32 bool first = true;
34 unsigned cmd;
35 vs.rewind(path_id);
36 while(!is_stop(cmd = vs.vertex(&x2, &y2)))
38 if(is_vertex(cmd))
40 if(first || is_move_to(cmd))
42 start_x = x2;
43 start_y = y2;
45 else
47 len += calc_distance(x1, y1, x2, y2);
49 x1 = x2;
50 y1 = y2;
51 first = false;
53 else
55 if(is_close(cmd) && !first)
57 len += calc_distance(x1, y1, start_x, start_y);
61 return len;
65 #endif