27 std::vector<int> deltas(aItemExtents.size(), 0);
30 if (aItemExtents.size() < 3)
34 const int totalSpace = aItemExtents.back().first - aItemExtents.front().second;
35 int totalGap = totalSpace;
37 for(
size_t i = 1; i < aItemExtents.size() - 1; ++i )
39 const auto& [start, end] = aItemExtents[i];
40 totalGap -= end - start;
43 const double perItemGap = totalGap / double( aItemExtents.size() - 1 );
46 int targetPos = aItemExtents.begin()->second;
49 for(
size_t i = 1; i < aItemExtents.size() - 1; ++i )
51 const auto& [start, end] = aItemExtents[i];
55 const double accumulatedGaps = i * perItemGap;
56 const int delta = targetPos - start +
KiROUND(accumulatedGaps);
61 targetPos += end - start;
69 std::vector<int> deltas(aItemPositions.size(), 0);
72 if (aItemPositions.size() < 3)
75 const int startPos = aItemPositions.front();
76 const int totalGaps = aItemPositions.back() - startPos;
77 const double itemGap = totalGaps / double( aItemPositions.size() - 1 );
80 for(
size_t i = 1; i < aItemPositions.size() - 1; ++i )
82 const int targetPos = startPos +
KiROUND( i * itemGap );
83 const int delta = targetPos - aItemPositions[i];
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
std::vector< int > GetDeltasForDistributeByGaps(const std::vector< std::pair< int, int > > &aItemExtents)
Given a list of 'n' item spans (e.g.
std::vector< int > GetDeltasForDistributeByPoints(const std::vector< int > &aItemPositions)