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);
48 auto start = segments[0]->start();
49 curve->set_x0(scale_x(start.x()));
50 curve->set_y0(scale_y(start.y()));
52 for(
const auto& score_segment : segments)
54 auto end = score_segment->end();
61 curve->set_y0_destination(*tween);
68template <
typename Segments>
69ossia::curve<double, float>
70floatCurve(
const Segments& segments,
const std::optional<ossia::destination>& tween)
72 ossia::curve<double, float> curve;
75 auto start = segments[0]->start();
76 curve.set_x0(start.x());
77 curve.set_y0(start.y());
79 for(
const auto& score_segment : segments)
81 auto end = score_segment->end();
82 curve.add_point((score_segment->*CurveTraits<float>::fun)(), end.x(), end.y());
87 curve.set_y0_destination(*tween);