OLD | NEW |
1 | 1 |
2 //---------------------------------------------------------------------------- | 2 //---------------------------------------------------------------------------- |
3 // Anti-Grain Geometry - Version 2.3 | 3 // Anti-Grain Geometry - Version 2.3 |
4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) | 4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) |
5 // | 5 // |
6 // Permission to copy, use, modify, sell and distribute this software | 6 // Permission to copy, use, modify, sell and distribute this software |
7 // is granted provided this copyright notice appears in all copies. | 7 // is granted provided this copyright notice appears in all copies. |
8 // This software is provided "as is" without express or implied | 8 // This software is provided "as is" without express or implied |
9 // warranty, and with no claim as to its suitability for any purpose. | 9 // warranty, and with no claim as to its suitability for any purpose. |
10 // | 10 // |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 typedef typename VertexConsumer::value_type coord_type; | 53 typedef typename VertexConsumer::value_type coord_type; |
54 FX_FLOAT a1 = FXSYS_atan2(dy1, dx1); | 54 FX_FLOAT a1 = FXSYS_atan2(dy1, dx1); |
55 FX_FLOAT a2 = FXSYS_atan2(dy2, dx2); | 55 FX_FLOAT a2 = FXSYS_atan2(dy2, dx2); |
56 FX_FLOAT da = a1 - a2; | 56 FX_FLOAT da = a1 - a2; |
57 bool ccw = da > 0 && da < FX_PI; | 57 bool ccw = da > 0 && da < FX_PI; |
58 if(width < 0) { | 58 if(width < 0) { |
59 width = -width; | 59 width = -width; |
60 } | 60 } |
61 da = FXSYS_acos(width / (width + ((1.0f / 8) / approximation_scale))) * 2; | 61 da = FXSYS_acos(width / (width + ((1.0f / 8) / approximation_scale))) * 2; |
62 out_vertices.add(coord_type(x + dx1, y + dy1)); | 62 out_vertices.add(coord_type(x + dx1, y + dy1)); |
63 if(!ccw) { | 63 if (da > 0) { |
64 if(a1 > a2) { | 64 if (!ccw) { |
65 a2 += 2 * FX_PI; | 65 if (a1 > a2) { |
| 66 a2 += 2 * FX_PI; |
66 } | 67 } |
67 a2 -= da / 4; | 68 a2 -= da / 4; |
68 a1 += da; | 69 a1 += da; |
69 while(a1 < a2) { | 70 while (a1 < a2) { |
70 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)), | 71 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)), |
71 y + (width * FXSYS_sin(a1)))); | 72 y + (width * FXSYS_sin(a1)))); |
72 a1 += da; | 73 a1 += da; |
73 } | 74 } |
74 } else { | 75 } else { |
75 if(a1 < a2) { | 76 if (a1 < a2) { |
76 a2 -= 2 * FX_PI; | 77 a2 -= 2 * FX_PI; |
77 } | 78 } |
78 a2 += da / 4; | 79 a2 += da / 4; |
79 a1 -= da; | 80 a1 -= da; |
80 while(a1 > a2) { | 81 while (a1 > a2) { |
81 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)), | 82 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)), |
82 y + (width * FXSYS_sin(a1)))); | 83 y + (width * FXSYS_sin(a1)))); |
83 a1 -= da; | 84 a1 -= da; |
84 } | 85 } |
| 86 } |
85 } | 87 } |
86 out_vertices.add(coord_type(x + dx2, y + dy2)); | 88 out_vertices.add(coord_type(x + dx2, y + dy2)); |
87 } | 89 } |
88 template<class VertexConsumer> | 90 template<class VertexConsumer> |
89 void stroke_calc_miter(VertexConsumer& out_vertices, | 91 void stroke_calc_miter(VertexConsumer& out_vertices, |
90 const vertex_dist& v0, | 92 const vertex_dist& v0, |
91 const vertex_dist& v1, | 93 const vertex_dist& v1, |
92 const vertex_dist& v2, | 94 const vertex_dist& v2, |
93 FX_FLOAT dx1, FX_FLOAT dy1, | 95 FX_FLOAT dx1, FX_FLOAT dy1, |
94 FX_FLOAT dx2, FX_FLOAT dy2, | 96 FX_FLOAT dx2, FX_FLOAT dy2, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 break; | 266 break; |
265 default: | 267 default: |
266 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); | 268 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); |
267 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); | 269 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); |
268 break; | 270 break; |
269 } | 271 } |
270 } | 272 } |
271 } | 273 } |
272 } | 274 } |
273 #endif | 275 #endif |
OLD | NEW |