9namespace score_to_ossia
12template <
typename Y_T>
18 static const constexpr auto fun = &Curve::SegmentModel::makeIntFunction;
19 static const constexpr auto scaled = &Curve::SegmentModel::makeScaledIntFunction;
25 static const constexpr auto fun = &Curve::SegmentModel::makeFloatFunction;
26 static const constexpr auto scaled = &Curve::SegmentModel::makeScaledFloatFunction;
32 static const constexpr auto fun = &Curve::SegmentModel::makeDoubleFunction;
37 typename X_T,
typename Y_T,
typename XScaleFun,
typename YScaleFun,
39std::shared_ptr<ossia::curve<X_T, Y_T>> curve(
40 XScaleFun scale_x, YScaleFun scale_y,
const Segments& segments,
41 const std::optional<ossia::destination>& tween)
43 auto curve = std::make_shared<ossia::curve<X_T, Y_T>>();
44 curve->reserve(segments.size() + 1);
50 auto start = segments[0]->start();
51 curve->set_x0(scale_x(start.x()));
52 curve->set_y0(scale_y(start.y()));
55 const double offset = scale_y(0.);
56 const double factor = double(scale_y(1.)) - offset;
57 for(
const auto& score_segment : segments)
59 auto end = score_segment->end();
67 curve->set_y0_destination(*tween);
74template <
typename Segments>
75ossia::curve<double, float>
76floatCurve(
const Segments& segments,
const std::optional<ossia::destination>& tween)
78 ossia::curve<double, float> curve;
81 auto start = segments[0]->start();
82 curve.set_x0(start.x());
83 curve.set_y0(start.y());
85 for(
const auto& score_segment : segments)
87 auto end = score_segment->end();
89 (score_segment->*CurveTraits<float>::scaled)(0., 1.), end.x(), end.y());
94 curve.set_y0_destination(*tween);