MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / calc_cap

Method calc_cap

dep/agg/include/agg_math_stroke.h:381–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379 //--------------------------------------------------------stroke_calc_cap
380 template <class VC>
381 void math_stroke<VC>::calc_cap(
382 VC& vc, const vertex_dist& v0, const vertex_dist& v1, double len)
383 {
384 vc.remove_all();
385
386 double dx1 = (v1.y - v0.y) / len;
387 double dy1 = (v1.x - v0.x) / len;
388 double dx2 = 0;
389 double dy2 = 0;
390
391 dx1 *= m_width;
392 dy1 *= m_width;
393
394 if (m_line_cap != round_cap)
395 {
396 if (m_line_cap == square_cap)
397 {
398 dx2 = dy1 * m_width_sign;
399 dy2 = dx1 * m_width_sign;
400 }
401 add_vertex(vc, v0.x - dx1 - dx2, v0.y + dy1 - dy2);
402 add_vertex(vc, v0.x + dx1 - dx2, v0.y - dy1 - dy2);
403 }
404 else
405 {
406 double da = std::acos(m_width_abs /
407 (m_width_abs + 0.125 / m_approx_scale)) *
408 2;
409 double a1;
410 int i;
411 int n = int(pi / da);
412
413 da = pi / (n + 1);
414 add_vertex(vc, v0.x - dx1, v0.y + dy1);
415 if (m_width_sign > 0)
416 {
417 a1 = std::atan2(dy1, -dx1);
418 a1 += da;
419 for (i = 0; i < n; i++)
420 {
421 add_vertex(vc,
422 v0.x + std::cos(a1) * m_width,
423 v0.y + std::sin(a1) * m_width);
424 a1 += da;
425 }
426 }
427 else
428 {
429 a1 = std::atan2(-dy1, dx1);
430 a1 -= da;
431 for (i = 0; i < n; i++)
432 {
433 add_vertex(vc,
434 v0.x + std::cos(a1) * m_width,
435 v0.y + std::sin(a1) * m_width);
436 a1 -= da;
437 }
438 }

Callers 1

vertexMethod · 0.80

Calls 1

remove_allMethod · 0.45

Tested by

no test coverage detected