OLD | NEW |
1 | 1 |
2 //---------------------------------------------------------------------------- | 2 //---------------------------------------------------------------------------- |
3 // XYQ: 2006-01-22 Copied from AGG project. | 3 // XYQ: 2006-01-22 Copied from AGG project. |
4 // TODO: This file uses intensive floating point operations, so it's NOT suitabl
e | 4 // TODO: This file uses intensive floating point operations, so it's NOT suitabl
e |
5 // for platforms like Symbian OS. We need to change to FIX format. | 5 // for platforms like Symbian OS. We need to change to FIX format. |
6 //---------------------------------------------------------------------------- | 6 //---------------------------------------------------------------------------- |
7 //---------------------------------------------------------------------------- | 7 //---------------------------------------------------------------------------- |
8 // Anti-Grain Geometry - Version 2.3 | 8 // Anti-Grain Geometry - Version 2.3 |
9 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) | 9 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) |
10 // | 10 // |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 FX_FLOAT x34 = (x3 + x4) / 2; | 54 FX_FLOAT x34 = (x3 + x4) / 2; |
55 FX_FLOAT y34 = (y3 + y4) / 2; | 55 FX_FLOAT y34 = (y3 + y4) / 2; |
56 FX_FLOAT x123 = (x12 + x23) / 2; | 56 FX_FLOAT x123 = (x12 + x23) / 2; |
57 FX_FLOAT y123 = (y12 + y23) / 2; | 57 FX_FLOAT y123 = (y12 + y23) / 2; |
58 FX_FLOAT x234 = (x23 + x34) / 2; | 58 FX_FLOAT x234 = (x23 + x34) / 2; |
59 FX_FLOAT y234 = (y23 + y34) / 2; | 59 FX_FLOAT y234 = (y23 + y34) / 2; |
60 FX_FLOAT x1234 = (x123 + x234) / 2; | 60 FX_FLOAT x1234 = (x123 + x234) / 2; |
61 FX_FLOAT y1234 = (y123 + y234) / 2; | 61 FX_FLOAT y1234 = (y123 + y234) / 2; |
62 FX_FLOAT dx = x4 - x1; | 62 FX_FLOAT dx = x4 - x1; |
63 FX_FLOAT dy = y4 - y1; | 63 FX_FLOAT dy = y4 - y1; |
64 FX_FLOAT d2 = FXSYS_fabs(FXSYS_Mul(x2 - x4, dy) - FXSYS_Mul(y2 - y4, dx)); | 64 FX_FLOAT d2 = FXSYS_fabs(((x2 - x4) * dy) - ((y2 - y4) * dx)); |
65 FX_FLOAT d3 = FXSYS_fabs(FXSYS_Mul(x3 - x4, dy) - FXSYS_Mul(y3 - y4, dx)); | 65 FX_FLOAT d3 = FXSYS_fabs(((x3 - x4) * dy) - ((y3 - y4) * dx)); |
66 switch((int(d2 > curve_collinearity_epsilon) << 1) + | 66 switch((int(d2 > curve_collinearity_epsilon) << 1) + |
67 int(d3 > curve_collinearity_epsilon)) { | 67 int(d3 > curve_collinearity_epsilon)) { |
68 case 0: | 68 case 0: |
69 if(FXSYS_fabs(x1 + x3 - x2 - x2) + | 69 if(FXSYS_fabs(x1 + x3 - x2 - x2) + |
70 FXSYS_fabs(y1 + y3 - y2 - y2) + | 70 FXSYS_fabs(y1 + y3 - y2 - y2) + |
71 FXSYS_fabs(x2 + x4 - x3 - x3) + | 71 FXSYS_fabs(x2 + x4 - x3 - x3) + |
72 FXSYS_fabs(y2 + y4 - y3 - y3) <= m_distance_tolerance_manhat
tan) { | 72 FXSYS_fabs(y2 + y4 - y3 - y3) <= m_distance_tolerance_manhat
tan) { |
73 m_points.add(point_type(x1234, y1234, path_flags_jr)); | 73 m_points.add(point_type(x1234, y1234, path_flags_jr)); |
74 return; | 74 return; |
75 } | 75 } |
76 break; | 76 break; |
77 case 1: | 77 case 1: |
78 if(FXSYS_Mul(d3, d3) <= FXSYS_Mul(m_distance_tolerance_square, | 78 if ((d3 * d3) <= |
79 FXSYS_Mul(dx, dx) + FXSYS_Mul(dy,
dy))) { | 79 (m_distance_tolerance_square * ((dx * dx) + (dy * dy)))) { |
80 m_points.add(point_type(x23, y23, path_flags_jr)); | 80 m_points.add(point_type(x23, y23, path_flags_jr)); |
81 return; | 81 return; |
82 } | 82 } |
83 break; | 83 break; |
84 case 2: | 84 case 2: |
85 if(FXSYS_Mul(d2, d2) <= FXSYS_Mul(m_distance_tolerance_square, | 85 if ((d2 * d2) <= |
86 FXSYS_Mul(dx, dx) + FXSYS_Mul(dy,
dy))) { | 86 (m_distance_tolerance_square * ((dx * dx) + (dy * dy)))) { |
87 m_points.add(point_type(x23, y23, path_flags_jr)); | 87 m_points.add(point_type(x23, y23, path_flags_jr)); |
88 return; | 88 return; |
89 } | 89 } |
90 break; | 90 break; |
91 case 3: | 91 case 3: |
92 if(FXSYS_Mul(d2 + d3, d2 + d3) <= FXSYS_Mul(m_distance_tolerance_squ
are, | 92 if (((d2 + d3) * (d2 + d3)) <= |
93 FXSYS_Mul(dx, dx) + FXSYS_Mul(dy, dy))) { | 93 (m_distance_tolerance_square * ((dx * dx) + (dy * dy)))) { |
94 m_points.add(point_type(x23, y23, path_flags_jr)); | 94 m_points.add(point_type(x23, y23, path_flags_jr)); |
95 return; | 95 return; |
96 } | 96 } |
97 break; | 97 break; |
98 } | 98 } |
99 recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1); | 99 recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1); |
100 recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1); | 100 recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1); |
101 } | 101 } |
102 void curve4_div::bezier(FX_FLOAT x1, FX_FLOAT y1, | 102 void curve4_div::bezier(FX_FLOAT x1, FX_FLOAT y1, |
103 FX_FLOAT x2, FX_FLOAT y2, | 103 FX_FLOAT x2, FX_FLOAT y2, |
104 FX_FLOAT x3, FX_FLOAT y3, | 104 FX_FLOAT x3, FX_FLOAT y3, |
105 FX_FLOAT x4, FX_FLOAT y4) | 105 FX_FLOAT x4, FX_FLOAT y4) |
106 { | 106 { |
107 m_points.add(point_type(x1, y1)); | 107 m_points.add(point_type(x1, y1)); |
108 recursive_bezier(x1, y1, x2, y2, x3, y3, x4, y4, 0); | 108 recursive_bezier(x1, y1, x2, y2, x3, y3, x4, y4, 0); |
109 m_points.add(point_type(x4, y4)); | 109 m_points.add(point_type(x4, y4)); |
110 } | 110 } |
111 } | 111 } |
OLD | NEW |