コード例 #1
0
Faded<T> Function<Faded<T>>::evaluate(const StyleCalculationParameters& parameters) const {
    Faded<T> result;

    float z = parameters.z;
    float fraction = std::fmod(z, 1.0f);
    std::chrono::duration<float> d = parameters.defaultFadeDuration;
    float t = std::min((parameters.now - parameters.zoomHistory.lastIntegerZoomTime) / d, 1.0f);
    float fromScale = 1.0f;
    float toScale = 1.0f;
    size_t from, to;

    if (z > parameters.zoomHistory.lastIntegerZoom) {
        result.t = fraction + (1.0f - fraction) * t;
        from = getBiggestStopLessThan(stops, z - 1.0f);
        to = getBiggestStopLessThan(stops, z);
        fromScale *= 2.0f;

    } else {
        result.t = 1 - (1 - t) * fraction;
        to = getBiggestStopLessThan(stops, z);
        from = getBiggestStopLessThan(stops, z + 1.0f);
        fromScale /= 2.0f;
    }

    result.from = stops[from].second;
    result.to = stops[to].second;
    result.fromScale = fromScale;
    result.toScale = toScale;
    return result;
}
コード例 #2
0
Faded<T> CrossFadedPropertyEvaluator<T>::operator()(const Function<T>& function) const {
    return calculate(getBiggestStopLessThan(function, parameters.z - 1.0f),
                     getBiggestStopLessThan(function, parameters.z),
                     getBiggestStopLessThan(function, parameters.z + 1.0f));
}