MCPcopy Create free account
hub / github.com/MyGUI/mygui / drawSpline

Method drawSpline

UnitTests/UnitTest_GraphView/BaseGraphView.h:483–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 }
482
483 void drawSpline(const ConnectionInfo& _info, int _offset, const MyGUI::Colour& _colour)
484 {
485 MyGUI::Widget* widget = getNextWidget();
486 widget->setColour(_colour);
487
488 MyGUI::ISubWidget* main = widget->getSubWidgetMain();
489 MyGUI::PolygonalSkin* polygonalSkin = main->castType<MyGUI::PolygonalSkin>();
490 polygonalSkin->setWidth(4.0f);
491
492 const size_t PointsNumber = 16;
493 std::vector<MyGUI::FloatPoint> basePoints;
494 basePoints.emplace_back((float)_info.point_start.left, (float)_info.point_start.top + _offset);
495 basePoints.emplace_back(
496 (float)_info.point_start.left + _info.start_offset.width,
497 (float)_info.point_start.top + _info.start_offset.height + _offset);
498 basePoints.emplace_back(
499 (float)_info.point_end.left + _info.end_offset.width,
500 (float)_info.point_end.top + _info.end_offset.height + _offset);
501 basePoints.emplace_back((float)_info.point_end.left, (float)_info.point_end.top + _offset);
502 std::vector<MyGUI::FloatPoint> splinePoints;
503 splinePoints.reserve(PointsNumber);
504 for (size_t i = 0; i < PointsNumber; ++i)
505 {
506 float t = float(i) / (PointsNumber - 1);
507 float left = basePoints[0].left * std::pow(1 - t, 3.0f) +
508 3 * basePoints[1].left * std::pow(1 - t, 2.0f) * t + 3 * basePoints[2].left * (1 - t) * t * t +
509 t * t * t * basePoints[3].left;
510 float top = basePoints[0].top * std::pow(1 - t, 3.0f) +
511 3 * basePoints[1].top * std::pow(1 - t, 2.0f) * t + 3 * basePoints[2].top * (1 - t) * t * t +
512 t * t * t * basePoints[3].top;
513 splinePoints.emplace_back(left, top);
514 }
515 polygonalSkin->setPoints(splinePoints);
516 }
517
518 void drawCurve(const ConnectionInfo& _info)
519 {

Callers

nothing calls this directly

Calls 5

getSubWidgetMainMethod · 0.80
setPointsMethod · 0.80
setColourMethod · 0.45
setWidthMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected