9namespace score_to_ossia
12template <
typename Y_T>
18 static const constexpr auto fun = &Curve::SegmentModel::makeIntFunction;
24 static const constexpr auto fun = &Curve::SegmentModel::makeFloatFunction;
31 static const constexpr auto fun = &Curve::SegmentModel::makeDoubleFunction;
35 typename X_T,
typename Y_T,
typename XScaleFun,
typename YScaleFun,
37std::shared_ptr<ossia::curve<X_T, Y_T>> curve(
38 XScaleFun scale_x, YScaleFun scale_y,
const Segments& segments,
39 const std::optional<ossia::destination>& tween)
41 auto curve = std::make_shared<ossia::curve<X_T, Y_T>>();
42 curve->reserve(segments.size() + 1);
44 auto start = segments[0]->start();
47 curve->set_x0(scale_x(start.x()));
48 curve->set_y0(scale_y(start.y()));
51 for(
const auto& score_segment : segments)
53 auto end = score_segment->end();
55 (score_segment->*CurveTraits<Y_T>::fun)(), scale_x(end.x()), scale_y(end.y()));
60 curve->set_y0_destination(*tween);
67template <
typename Segments>
68ossia::curve<double, float>
69floatCurve(
const Segments& segments,
const std::optional<ossia::destination>& tween)
71 ossia::curve<double, float> curve;
73 auto start = segments[0]->start();
76 curve.set_x0(start.x());
77 curve.set_y0(start.y());
80 for(
const auto& score_segment : segments)
82 auto end = score_segment->end();
83 curve.add_point((score_segment->*CurveTraits<float>::fun)(), end.x(), end.y());
88 curve.set_y0_destination(*tween);