MCPcopy Create free account
hub / github.com/MapServer/MapServer / calc_cap

Method calc_cap

renderers/agg/include/agg_math_stroke.h:317–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315 //--------------------------------------------------------stroke_calc_cap
316 template<class VC>
317 void math_stroke<VC>::calc_cap(VC& vc,
318 const vertex_dist& v0,
319 const vertex_dist& v1,
320 double len)
321 {
322 vc.remove_all();
323
324 double dx1 = (v1.y - v0.y) / len;
325 double dy1 = (v1.x - v0.x) / len;
326 double dx2 = 0;
327 double dy2 = 0;
328
329 dx1 *= m_width;
330 dy1 *= m_width;
331
332 if(m_line_cap != round_cap)
333 {
334 if(m_line_cap == square_cap)
335 {
336 dx2 = dy1 * m_width_sign;
337 dy2 = dx1 * m_width_sign;
338 }
339 add_vertex(vc, v0.x - dx1 - dx2, v0.y + dy1 - dy2);
340 add_vertex(vc, v0.x + dx1 - dx2, v0.y - dy1 - dy2);
341 }
342 else
343 {
344 double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
345 double a1;
346 int i;
347 int n = int(pi / da);
348
349 da = pi / (n + 1);
350 add_vertex(vc, v0.x - dx1, v0.y + dy1);
351 if(m_width_sign > 0)
352 {
353 a1 = atan2(dy1, -dx1);
354 a1 += da;
355 for(i = 0; i < n; i++)
356 {
357 add_vertex(vc, v0.x + cos(a1) * m_width,
358 v0.y + sin(a1) * m_width);
359 a1 += da;
360 }
361 }
362 else
363 {
364 a1 = atan2(-dy1, dx1);
365 a1 -= da;
366 for(i = 0; i < n; i++)
367 {
368 add_vertex(vc, v0.x + cos(a1) * m_width,
369 v0.y + sin(a1) * m_width);
370 a1 -= da;
371 }
372 }
373 add_vertex(vc, v0.x + dx1, v0.y - dy1);
374 }

Callers 1

vertexMethod · 0.80

Calls 1

remove_allMethod · 0.45

Tested by

no test coverage detected