Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2012 Mike Solomon <mike@mikesolomon.org> | 4 Copyright (C) 2012 Mike Solomon <mike@mikesolomon.org> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 [ a c e ] | 27 [ a c e ] |
28 [ b d f ] | 28 [ b d f ] |
29 [ 0 0 1 ] | 29 [ 0 0 1 ] |
30 when this transforms a point (x,y), the point is written as matrix: | 30 when this transforms a point (x,y), the point is written as matrix: |
31 [ x ] | 31 [ x ] |
32 [ y ] | 32 [ y ] |
33 [ 1 ] | 33 [ 1 ] |
34 */ | 34 */ |
35 | 35 |
36 #include <pango/pango-matrix.h> | 36 #include <pango/pango-matrix.h> |
37 #include <complex> | |
38 #include "box.hh" | 37 #include "box.hh" |
39 #include "bezier.hh" | 38 #include "bezier.hh" |
40 #include "dimensions.hh" | 39 #include "dimensions.hh" |
41 #include "font-metric.hh" | 40 #include "font-metric.hh" |
42 #include "grob.hh" | 41 #include "grob.hh" |
43 #include "interval.hh" | 42 #include "interval.hh" |
44 #include "freetype.hh" | 43 #include "freetype.hh" |
45 #include "misc.hh" | 44 #include "misc.hh" |
46 #include "offset.hh" | 45 #include "offset.hh" |
47 #include "modified-font-metric.hh" | 46 #include "modified-font-metric.hh" |
48 #include "open-type-font.hh" | 47 #include "open-type-font.hh" |
49 #include "pango-font.hh" | 48 #include "pango-font.hh" |
50 #include "pointer-group-interface.hh" | 49 #include "pointer-group-interface.hh" |
51 #include "lily-guile.hh" | 50 #include "lily-guile.hh" |
52 #include "real.hh" | 51 #include "real.hh" |
53 #include "rest.hh" | 52 #include "rest.hh" |
54 #include "stencil.hh" | 53 #include "stencil.hh" |
55 #include "string-convert.hh" | 54 #include "string-convert.hh" |
56 #include "skyline.hh" | 55 #include "skyline.hh" |
57 #include "skyline-pair.hh" | 56 #include "skyline-pair.hh" |
58 #include "spanner.hh" | 57 #include "spanner.hh" |
59 using namespace std; | 58 using namespace std; |
60 | 59 |
61 Real QUANTIZATION_UNIT = 0.2; | 60 Real QUANTIZATION_UNIT = 0.2; |
62 | 61 |
63 void create_path_cap (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings , PangoMatrix trans, Offset pt, Real rad, Real slope, Direction d); | 62 void create_path_cap (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings , PangoMatrix trans, Offset pt, Real rad, Offset dir); |
lemzwerg
2015/06/30 04:39:54
80 characters per line, please...
dak
2015/06/30 05:49:27
Hey, it's shorter than the original. Will do, but
| |
64 | 63 |
65 struct Transform_matrix_and_expression | 64 struct Transform_matrix_and_expression |
66 { | 65 { |
67 PangoMatrix tm_; | 66 PangoMatrix tm_; |
68 SCM expr_; | 67 SCM expr_; |
69 | 68 |
70 Transform_matrix_and_expression (PangoMatrix tm, SCM expr); | 69 Transform_matrix_and_expression (PangoMatrix tm, SCM expr); |
71 }; | 70 }; |
72 | 71 |
73 Transform_matrix_and_expression::Transform_matrix_and_expression (PangoMatrix tm , SCM expr) | 72 Transform_matrix_and_expression::Transform_matrix_and_expression (PangoMatrix tm , SCM expr) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 SCM_UNDEFINED)))) | 139 SCM_UNDEFINED)))) |
141 return l; | 140 return l; |
142 SCM res = get_path_list (scm_car (l)); | 141 SCM res = get_path_list (scm_car (l)); |
143 if (scm_is_false (res)) | 142 if (scm_is_false (res)) |
144 return get_path_list (scm_cdr (l)); | 143 return get_path_list (scm_cdr (l)); |
145 return res; | 144 return res; |
146 } | 145 } |
147 return SCM_BOOL_F; | 146 return SCM_BOOL_F; |
148 } | 147 } |
149 | 148 |
150 Real | 149 // Gets an orthogonal vector with same size to orig, pointing left |
151 perpendicular_slope (Real s) | 150 // (in the complex domain, a multiplication by i) |
151 | |
152 Offset | |
153 get_normal (Offset orig) | |
152 { | 154 { |
153 if (s == 0.0) | 155 return Offset (-orig[Y_AXIS], orig[X_AXIS]); |
154 return infinity_f; | |
155 if (s == infinity_f) | |
156 return 0.0; | |
157 return -1.0 / s; | |
158 } | 156 } |
159 | 157 |
160 //// END UTILITY FUNCTIONS | 158 //// END UTILITY FUNCTIONS |
161 | 159 |
162 /* | 160 /* |
163 below, for all of the functions make_X_boxes, the expression | 161 below, for all of the functions make_X_boxes, the expression |
164 is always unpacked into variables. | 162 is always unpacked into variables. |
165 then, after a line of /////, there are manipulations of these variables | 163 then, after a line of /////, there are manipulations of these variables |
166 (there may be no manipulations necessary depending on the function) | 164 (there may be no manipulations necessary depending on the function) |
167 afterwards, there is another ///// followed by the creation of points | 165 afterwards, there is another ///// followed by the creation of points |
168 and boxes | 166 and boxes |
169 */ | 167 */ |
170 | 168 |
171 void | 169 void |
172 make_draw_line_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings , PangoMatrix trans, SCM expr, bool use_building) | 170 make_draw_line_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings , PangoMatrix trans, SCM expr, bool use_building) |
173 { | 171 { |
174 Real thick = robust_scm2double (scm_car (expr), 0.0); | 172 Real thick = robust_scm2double (scm_car (expr), 0.0); |
175 expr = scm_cdr (expr); | 173 expr = scm_cdr (expr); |
176 Real x0 = robust_scm2double (scm_car (expr), 0.0); | 174 Real x0 = robust_scm2double (scm_car (expr), 0.0); |
177 expr = scm_cdr (expr); | 175 expr = scm_cdr (expr); |
178 Real y0 = robust_scm2double (scm_car (expr), 0.0); | 176 Real y0 = robust_scm2double (scm_car (expr), 0.0); |
179 expr = scm_cdr (expr); | 177 expr = scm_cdr (expr); |
180 Real x1 = robust_scm2double (scm_car (expr), 0.0); | 178 Real x1 = robust_scm2double (scm_car (expr), 0.0); |
181 expr = scm_cdr (expr); | 179 expr = scm_cdr (expr); |
182 Real y1 = robust_scm2double (scm_car (expr), 0.0); | 180 Real y1 = robust_scm2double (scm_car (expr), 0.0); |
183 Real slope = x1 == x0 ? infinity_f : (y1 - y0) / (x1 - x0); | 181 |
184 ////////////////////// | 182 ////////////////////// |
185 if (x1 < x0) | 183 if (x1 < x0) |
186 { | 184 { |
187 swap (x0, x1); | 185 swap (x0, x1); |
188 swap (y0, y1); | 186 swap (y0, y1); |
189 } | 187 } |
190 Offset left (x0, y0); | 188 Offset left (x0, y0); |
191 Offset right (x1, y1); | 189 Offset right (x1, y1); |
190 Offset dir = (right - left).direction (); | |
192 Direction d = DOWN; | 191 Direction d = DOWN; |
193 do | 192 do |
194 { | 193 { |
195 Offset inter_l = get_point_in_y_direction (left, perpendicular_slope (slop e), thick / 2, d); | 194 Offset outward = d * get_normal ((thick / 2) * dir); |
196 Offset inter_r = get_point_in_y_direction (right, perpendicular_slope (slo pe), thick / 2, d); | 195 Offset inter_l = left + outward; |
196 Offset inter_r = right + outward; | |
197 pango_matrix_transform_point (&trans, &inter_l[X_AXIS], &inter_l[Y_AXIS]); | 197 pango_matrix_transform_point (&trans, &inter_l[X_AXIS], &inter_l[Y_AXIS]); |
198 pango_matrix_transform_point (&trans, &inter_r[X_AXIS], &inter_r[Y_AXIS]); | 198 pango_matrix_transform_point (&trans, &inter_r[X_AXIS], &inter_r[Y_AXIS]); |
199 if ((inter_l[X_AXIS] == inter_r[X_AXIS]) || (inter_l[Y_AXIS] == inter_r[Y_ AXIS])) | 199 if ((inter_l[X_AXIS] == inter_r[X_AXIS]) || (inter_l[Y_AXIS] == inter_r[Y_ AXIS])) |
200 { | 200 { |
201 Box b; | 201 Box b; |
202 b.add_point (inter_l); | 202 b.add_point (inter_l); |
203 b.add_point (inter_r); | 203 b.add_point (inter_r); |
204 boxes.push_back (b); | 204 boxes.push_back (b); |
205 } | 205 } |
206 else if (use_building) | 206 else if (use_building) |
207 buildings.push_back (Drul_array<Offset> (inter_l, inter_r)); | 207 buildings.push_back (Drul_array<Offset> (inter_l, inter_r)); |
208 else | 208 else |
209 { | 209 { |
210 Offset inter_l = get_point_in_y_direction (left, perpendicular_slope ( slope), thick / 2, d); | 210 Real length = (inter_l - inter_r).length (); |
211 Offset inter_r = get_point_in_y_direction (right, perpendicular_slope (slope), thick / 2, d); | |
212 pango_matrix_transform_point (&trans, &inter_l[X_AXIS], &inter_l[Y_AXI S]); | |
213 pango_matrix_transform_point (&trans, &inter_r[X_AXIS], &inter_r[Y_AXI S]); | |
214 Real length = sqrt (((inter_l[X_AXIS] - inter_r[X_AXIS]) * (inter_l[X_ AXIS] - inter_r[X_AXIS])) + ((inter_l[Y_AXIS] - inter_r[Y_AXIS]) * (inter_l[Y_AX IS] - inter_r[Y_AXIS]))); | |
215 | 211 |
216 vsize passes = (vsize) ((length * 2) + 1); | 212 vsize passes = (vsize) ((length * 2) + 1); |
217 vector<Offset> points; | 213 vector<Offset> points; |
218 | 214 |
219 for (vsize i = 0; i < 1 + passes; i++) | 215 for (vsize i = 0; i < 1 + passes; i++) |
220 { | 216 { |
221 Offset pt (linear_map (x0, x1, 0, passes, i), | 217 Offset pt (linear_map (x0, x1, 0, passes, i), |
222 linear_map (y0, y1, 0, passes, i)); | 218 linear_map (y0, y1, 0, passes, i)); |
223 Offset inter = get_point_in_y_direction (pt, perpendicular_slope ( slope), thick / 2, d); | 219 Offset inter = pt + outward; |
224 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXI S]); | 220 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXI S]); |
225 points.push_back (inter); | 221 points.push_back (inter); |
226 } | 222 } |
227 for (vsize i = 0; i < points.size () - 1; i++) | 223 for (vsize i = 0; i < points.size () - 1; i++) |
228 { | 224 { |
229 Box b; | 225 Box b; |
230 b.add_point (points[i]); | 226 b.add_point (points[i]); |
231 b.add_point (points[i + 1]); | 227 b.add_point (points[i + 1]); |
232 boxes.push_back (b); | 228 boxes.push_back (b); |
233 } | 229 } |
234 } | 230 } |
235 } | 231 } |
236 while (flip (&d) != DOWN); | 232 while (flip (&d) != DOWN); |
237 | 233 |
238 if (thick > 0.0) | 234 if (thick > 0.0) |
239 { | 235 { |
240 // beg line cap | 236 // beg line cap |
241 create_path_cap (boxes, | 237 create_path_cap (boxes, |
242 buildings, | 238 buildings, |
243 trans, | 239 trans, |
244 Offset (x0, y0), | 240 left, |
245 thick / 2, | 241 thick / 2, |
246 perpendicular_slope (slope), | 242 -dir); |
247 Direction (sign (slope))); | |
248 | 243 |
249 // end line cap | 244 // end line cap |
250 create_path_cap (boxes, | 245 create_path_cap (boxes, |
251 buildings, | 246 buildings, |
252 trans, | 247 trans, |
253 Offset (x1, y1), | 248 right, |
254 thick / 2, | 249 thick / 2, |
255 perpendicular_slope (slope), | 250 dir); |
256 Direction (sign (-slope))); | |
257 } | 251 } |
258 } | 252 } |
259 | 253 |
260 void | 254 void |
261 make_partial_ellipse_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &bui ldings, PangoMatrix trans, SCM expr) | 255 make_partial_ellipse_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &bui ldings, PangoMatrix trans, SCM expr) |
262 { | 256 { |
263 Real x_rad = robust_scm2double (scm_car (expr), 0.0); | 257 Real x_rad = robust_scm2double (scm_car (expr), 0.0); |
264 expr = scm_cdr (expr); | 258 expr = scm_cdr (expr); |
265 Real y_rad = robust_scm2double (scm_car (expr), 0.0); | 259 Real y_rad = robust_scm2double (scm_car (expr), 0.0); |
266 expr = scm_cdr (expr); | 260 expr = scm_cdr (expr); |
267 Real start = robust_scm2double (scm_car (expr), 0.0); | 261 Real start = robust_scm2double (scm_car (expr), 0.0); |
268 expr = scm_cdr (expr); | 262 expr = scm_cdr (expr); |
269 Real end = robust_scm2double (scm_car (expr), 0.0); | 263 Real end = robust_scm2double (scm_car (expr), 0.0); |
270 expr = scm_cdr (expr); | 264 expr = scm_cdr (expr); |
271 Real th = robust_scm2double (scm_car (expr), 0.0); | 265 Real th = robust_scm2double (scm_car (expr), 0.0); |
272 expr = scm_cdr (expr); | 266 expr = scm_cdr (expr); |
273 bool connect = to_boolean (scm_car (expr)); | 267 bool connect = to_boolean (scm_car (expr)); |
274 expr = scm_cdr (expr); | 268 expr = scm_cdr (expr); |
275 bool fill = to_boolean (scm_car (expr)); | 269 bool fill = to_boolean (scm_car (expr)); |
276 ////////////////////// | 270 ////////////////////// |
277 start = M_PI * start / 180; | 271 start = M_PI * start / 180; |
278 end = M_PI * end / 180; | 272 end = M_PI * end / 180; |
279 if (end == start) | 273 if (end == start) |
280 end += (2 * M_PI); | 274 end += (2 * M_PI); |
281 complex<Real> sunit = polar (1.0, start); | 275 Offset sp (cos (start) * x_rad, sin (start) * y_rad); |
282 complex<Real> eunit = polar (1.0, end); | 276 Offset ep (cos (end) * x_rad, sin (end) * y_rad); |
283 Offset sp (real (sunit) * x_rad, imag (sunit) * y_rad); | |
284 Offset ep (real (eunit) * x_rad, imag (eunit) * y_rad); | |
285 ////////////////////// | 277 ////////////////////// |
286 Drul_array<vector<Offset> > points; | 278 Drul_array<vector<Offset> > points; |
287 Direction d = DOWN; | 279 Direction d = DOWN; |
288 int quantization = max (1, (int) (((x_rad * trans.xx) + (y_rad * trans.yy)) * M_PI / QUANTIZATION_UNIT)); | 280 int quantization = max (1, (int) (((x_rad * trans.xx) + (y_rad * trans.yy)) * M_PI / QUANTIZATION_UNIT)); |
289 do | 281 do |
290 { | 282 { |
291 for (vsize i = 0; i < 1 + (vsize) quantization; i++) | 283 for (vsize i = 0; i < 1 + (vsize) quantization; i++) |
292 { | 284 { |
293 Real ang = linear_map (start, end, 0, quantization, i); | 285 Real ang = linear_map (start, end, 0, quantization, i); |
294 complex<Real> coord = polar (1.0, ang); | 286 Offset pt (cos (ang) * x_rad, sin (ang) * y_rad); |
295 Offset pt (real (coord) * x_rad, | 287 Offset inter = pt + d * get_normal ((th/2) * pt.direction ()); |
296 imag (coord) * y_rad); | |
297 Real slope = pt[Y_AXIS] / pt[X_AXIS]; | |
298 Offset inter = get_point_in_y_direction (pt, perpendicular_slope (slop e), th / 2, d); | |
299 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXIS]); | 288 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXIS]); |
300 points[d].push_back (inter); | 289 points[d].push_back (inter); |
301 } | 290 } |
302 } | 291 } |
303 while (flip (&d) != DOWN); | 292 while (flip (&d) != DOWN); |
304 | 293 |
305 for (vsize i = 0; i < points[DOWN].size () - 1; i++) | 294 for (vsize i = 0; i < points[DOWN].size () - 1; i++) |
306 { | 295 { |
307 Box b; | 296 Box b; |
308 do | 297 do |
(...skipping 11 matching lines...) Expand all Loading... | |
320 scm_from_double (sp[X_AXIS]), | 309 scm_from_double (sp[X_AXIS]), |
321 scm_from_double (sp[Y_AXIS]), | 310 scm_from_double (sp[Y_AXIS]), |
322 scm_from_double (ep[X_AXIS]), | 311 scm_from_double (ep[X_AXIS]), |
323 scm_from_double (ep[Y_AXIS])), | 312 scm_from_double (ep[Y_AXIS])), |
324 false); | 313 false); |
325 } | 314 } |
326 | 315 |
327 if (th > 0.0) | 316 if (th > 0.0) |
328 { | 317 { |
329 // beg line cap | 318 // beg line cap |
330 complex<Real> coord = polar (1.0, start); | 319 Offset pt (cos (start) * x_rad, sin (start) * y_rad); |
331 Offset pt (real (coord) * x_rad, | |
332 imag (coord) * y_rad); | |
333 Real slope = pt[Y_AXIS] / pt[X_AXIS]; | |
334 create_path_cap (boxes, | 320 create_path_cap (boxes, |
335 buildings, | 321 buildings, |
336 trans, | 322 trans, |
337 pt, | 323 pt, |
338 th / 2, | 324 th / 2, |
339 perpendicular_slope (slope), | 325 -get_normal (pt)); |
340 Direction (sign (slope))); | |
341 | 326 |
342 // end line cap | 327 // end line cap |
343 coord = polar (1.0, start); | 328 pt = Offset (cos (end) * x_rad, sin (end) * y_rad); |
344 pt = Offset (real (coord) * x_rad, | |
345 imag (coord) * y_rad); | |
346 slope = pt[Y_AXIS] / pt[X_AXIS]; | |
347 create_path_cap (boxes, | 329 create_path_cap (boxes, |
348 buildings, | 330 buildings, |
349 trans, | 331 trans, |
350 pt, | 332 pt, |
351 th / 2, | 333 th / 2, |
352 perpendicular_slope (slope), | 334 get_normal (pt)); |
353 Direction (sign (-slope))); | |
354 } | 335 } |
355 } | 336 } |
356 | 337 |
357 void | 338 void |
358 make_round_filled_box_boxes (vector<Box> &boxes, PangoMatrix trans, SCM expr) | 339 make_round_filled_box_boxes (vector<Box> &boxes, PangoMatrix trans, SCM expr) |
359 { | 340 { |
360 Real left = robust_scm2double (scm_car (expr), 0.0); | 341 Real left = robust_scm2double (scm_car (expr), 0.0); |
361 expr = scm_cdr (expr); | 342 expr = scm_cdr (expr); |
362 Real right = robust_scm2double (scm_car (expr), 0.0); | 343 Real right = robust_scm2double (scm_car (expr), 0.0); |
363 expr = scm_cdr (expr); | 344 expr = scm_cdr (expr); |
364 Real bottom = robust_scm2double (scm_car (expr), 0.0); | 345 Real bottom = robust_scm2double (scm_car (expr), 0.0); |
365 expr = scm_cdr (expr); | 346 expr = scm_cdr (expr); |
366 Real top = robust_scm2double (scm_car (expr), 0.0); | 347 Real top = robust_scm2double (scm_car (expr), 0.0); |
367 expr = scm_cdr (expr); | 348 expr = scm_cdr (expr); |
368 Real th = robust_scm2double (scm_car (expr), 0.0); | 349 Real th = robust_scm2double (scm_car (expr), 0.0); |
369 ////////////////////// | 350 ////////////////////// |
370 vector<Offset> points; | 351 vector<Offset> points; |
371 Box b; | 352 Box b; |
372 Offset p0 = Offset (-left - (th / 2), -bottom - (th / 2)); | 353 Offset p0 = Offset (-left - (th / 2), -bottom - (th / 2)); |
373 Offset p1 = Offset (right + (th / 2), top + (th / 2)); | 354 Offset p1 = Offset (right + (th / 2), top + (th / 2)); |
374 pango_matrix_transform_point (&trans, &p0[X_AXIS], &p0[Y_AXIS]); | 355 pango_matrix_transform_point (&trans, &p0[X_AXIS], &p0[Y_AXIS]); |
375 pango_matrix_transform_point (&trans, &p1[X_AXIS], &p1[Y_AXIS]); | 356 pango_matrix_transform_point (&trans, &p1[X_AXIS], &p1[Y_AXIS]); |
376 b.add_point (p0); | 357 b.add_point (p0); |
377 b.add_point (p1); | 358 b.add_point (p1); |
378 boxes.push_back (b); | 359 boxes.push_back (b); |
379 } | 360 } |
380 | 361 |
381 void | 362 void |
382 create_path_cap (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings, Pan goMatrix trans, Offset pt, Real rad, Real slope, Direction d) | 363 create_path_cap (vector<Box> &boxes, vector<Drul_array<Offset> > &buildings, Pan goMatrix trans, Offset pt, Real rad, Offset dir) |
lemzwerg
2015/06/30 04:39:54
ditto
| |
383 { | 364 { |
384 Real angle = atan (slope) * 180 / M_PI; | 365 Real angle = dir.angle_degrees (); |
385 Real other = angle > 180 ? angle - 180 : angle + 180; | |
386 if (angle < other) | |
387 { | |
388 Real holder = other; | |
389 other = angle; | |
390 angle = holder; | |
391 } | |
392 other = (slope >= 0 && d == DOWN) || (slope < 0 && d == UP) | |
393 ? other + 360.0 | |
394 : other; | |
395 PangoMatrix new_trans (trans); | 366 PangoMatrix new_trans (trans); |
396 pango_matrix_translate (&new_trans, pt[X_AXIS], pt[Y_AXIS]); | 367 pango_matrix_translate (&new_trans, pt[X_AXIS], pt[Y_AXIS]); |
397 make_partial_ellipse_boxes (boxes, buildings, new_trans, | 368 make_partial_ellipse_boxes (boxes, buildings, new_trans, |
398 scm_list_n (scm_from_double (rad), | 369 scm_list_n (scm_from_double (rad), |
399 scm_from_double (rad), | 370 scm_from_double (rad), |
400 scm_from_double (angle), | 371 scm_from_double (angle-90), |
401 scm_from_double (other), | 372 scm_from_double (angle+90), |
402 scm_from_double (0.0), | 373 scm_from_double (0.0), |
403 SCM_BOOL_F, | 374 SCM_BOOL_F, |
404 SCM_BOOL_F, | 375 SCM_BOOL_F, |
405 SCM_UNDEFINED)); | 376 SCM_UNDEFINED)); |
406 } | 377 } |
407 | 378 |
408 void | 379 void |
409 make_draw_bezier_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &buildin gs, PangoMatrix trans, SCM expr) | 380 make_draw_bezier_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &buildin gs, PangoMatrix trans, SCM expr) |
410 { | 381 { |
411 Real th = robust_scm2double (scm_car (expr), 0.0); | 382 Real th = robust_scm2double (scm_car (expr), 0.0); |
(...skipping 29 matching lines...) Expand all Loading... | |
441 pango_matrix_transform_point (&trans, &temp3[X_AXIS], &temp3[Y_AXIS]); | 412 pango_matrix_transform_point (&trans, &temp3[X_AXIS], &temp3[Y_AXIS]); |
442 ////////////////////// | 413 ////////////////////// |
443 Drul_array<vector<Offset> > points; | 414 Drul_array<vector<Offset> > points; |
444 Direction d = DOWN; | 415 Direction d = DOWN; |
445 int quantization = int (((temp1 - temp0).length () | 416 int quantization = int (((temp1 - temp0).length () |
446 + (temp2 - temp1).length () | 417 + (temp2 - temp1).length () |
447 + (temp3 - temp2).length ()) | 418 + (temp3 - temp2).length ()) |
448 / QUANTIZATION_UNIT); | 419 / QUANTIZATION_UNIT); |
449 do | 420 do |
450 { | 421 { |
451 Offset first = get_point_in_y_direction (curve.control_[0], perpendicular_ slope (curve.slope_at_point (0.0)), th / 2, d); | 422 Offset first = curve.control_[0] |
423 + d * get_normal ((th / 2) * curve.dir_at_point (0.0)); | |
452 pango_matrix_transform_point (&trans, &first[X_AXIS], &first[Y_AXIS]); | 424 pango_matrix_transform_point (&trans, &first[X_AXIS], &first[Y_AXIS]); |
453 points[d].push_back (first); | 425 points[d].push_back (first); |
454 for (vsize i = 1; i < (vsize) quantization; i++) | 426 for (vsize i = 1; i < (vsize) quantization; i++) |
455 { | 427 { |
456 Real pt = (i * 1.0) / quantization; | 428 Real pt = (i * 1.0) / quantization; |
457 Offset inter = get_point_in_y_direction (curve.curve_point (pt), perpe ndicular_slope (curve.slope_at_point (pt)), th / 2, d); | 429 Offset inter = curve.curve_point (pt) |
430 + d * get_normal ((th / 2) *curve.dir_at_point (pt)); | |
458 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXIS]); | 431 pango_matrix_transform_point (&trans, &inter[X_AXIS], &inter[Y_AXIS]); |
459 points[d].push_back (inter); | 432 points[d].push_back (inter); |
460 } | 433 } |
461 Offset last = get_point_in_y_direction (curve.control_[3], curve.slope_at_ point (1.0), th / 2, d); | 434 Offset last = curve.control_[3] |
435 + d * get_normal ((th / 2) * curve.dir_at_point (1.0)); | |
462 pango_matrix_transform_point (&trans, &last[X_AXIS], &last[Y_AXIS]); | 436 pango_matrix_transform_point (&trans, &last[X_AXIS], &last[Y_AXIS]); |
463 points[d].push_back (last); | 437 points[d].push_back (last); |
464 } | 438 } |
465 while (flip (&d) != DOWN); | 439 while (flip (&d) != DOWN); |
466 | 440 |
467 for (vsize i = 0; i < points[DOWN].size () - 1; i++) | 441 for (vsize i = 0; i < points[DOWN].size () - 1; i++) |
468 { | 442 { |
469 Box b; | 443 Box b; |
470 do | 444 do |
471 { | 445 { |
472 b.add_point (points[d][i]); | 446 b.add_point (points[d][i]); |
473 b.add_point (points[d][i + 1]); | 447 b.add_point (points[d][i + 1]); |
474 } | 448 } |
475 while (flip (&d) != DOWN); | 449 while (flip (&d) != DOWN); |
476 boxes.push_back (b); | 450 boxes.push_back (b); |
477 } | 451 } |
478 | 452 |
479 // beg line cap | |
480 if (th >= 0) | 453 if (th >= 0) |
481 { | 454 { |
482 Real slope = curve.slope_at_point (0.0); | 455 // beg line cap |
483 d = Direction (sign (slope == 0.0 || abs (slope) == infinity_f | |
484 ? curve.slope_at_point (0.0001) | |
485 : slope)); | |
486 | |
487 create_path_cap (boxes, | 456 create_path_cap (boxes, |
488 buildings, | 457 buildings, |
489 trans, | 458 trans, |
490 curve.control_[0], | 459 curve.control_[0], |
491 th / 2, | 460 th / 2, |
492 perpendicular_slope (curve.slope_at_point (0.0)), | 461 -curve.dir_at_point (0.0)); |
493 d); | |
494 | 462 |
495 // end line cap | 463 // end line cap |
496 slope = curve.slope_at_point (1.0); | |
497 d = Direction (sign (slope == 0.0 || abs (slope) == infinity_f | |
498 ? curve.slope_at_point (0.9999) | |
499 : slope)); | |
500 | |
501 create_path_cap (boxes, | 464 create_path_cap (boxes, |
502 buildings, | 465 buildings, |
503 trans, | 466 trans, |
504 curve.control_[3], | 467 curve.control_[3], |
505 th / 2, | 468 th / 2, |
506 perpendicular_slope (curve.slope_at_point (1.0)), | 469 curve.dir_at_point (1.0)); |
507 d); | |
508 } | 470 } |
509 } | 471 } |
510 | 472 |
511 /* | 473 /* |
512 converts a path into lists of 4 (line) or 8 (curve) absolute coordinates | 474 converts a path into lists of 4 (line) or 8 (curve) absolute coordinates |
513 for example: | 475 for example: |
514 '(moveto 1 2 lineto 3 4 rlineto -1 -1 curveto 3 3 5 5 6 6 rcurveto -1 -1 -1 -1 -1 -1 closepath) | 476 '(moveto 1 2 lineto 3 4 rlineto -1 -1 curveto 3 3 5 5 6 6 rcurveto -1 -1 -1 -1 -1 -1 closepath) |
515 becomes | 477 becomes |
516 '((1 2 3 4) | 478 '((1 2 3 4) |
517 (3 4 2 3) | 479 (3 4 2 3) |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 | 1124 |
1163 MAKE_SCHEME_CALLBACK (Grob, pure_horizontal_skylines_from_element_stencils, 3); | 1125 MAKE_SCHEME_CALLBACK (Grob, pure_horizontal_skylines_from_element_stencils, 3); |
1164 SCM | 1126 SCM |
1165 Grob::pure_horizontal_skylines_from_element_stencils (SCM smob, SCM beg_scm, SCM end_scm) | 1127 Grob::pure_horizontal_skylines_from_element_stencils (SCM smob, SCM beg_scm, SCM end_scm) |
1166 { | 1128 { |
1167 Grob *me = unsmob<Grob> (smob); | 1129 Grob *me = unsmob<Grob> (smob); |
1168 int beg = robust_scm2int (beg_scm, 0); | 1130 int beg = robust_scm2int (beg_scm, 0); |
1169 int end = robust_scm2int (end_scm, 0); | 1131 int end = robust_scm2int (end_scm, 0); |
1170 return internal_skylines_from_element_stencils (me, Y_AXIS, true, beg, end); | 1132 return internal_skylines_from_element_stencils (me, Y_AXIS, true, beg, end); |
1171 } | 1133 } |
OLD | NEW |