| Index: ui/gfx/animation/steps.cc
|
| diff --git a/ui/gfx/animation/steps.cc b/ui/gfx/animation/steps.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0fe6a47cd9e29c3da48d8d98b4ce653ad60192e0
|
| --- /dev/null
|
| +++ b/ui/gfx/animation/steps.cc
|
| @@ -0,0 +1,39 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/gfx/animation/steps.h"
|
| +
|
| +#include <cmath>
|
| +
|
| +#include "base/logging.h"
|
| +
|
| +template <class T>
|
| +T clamp(T value, T min, T max) {
|
| + if (value < min)
|
| + value = min;
|
| + if (value > max)
|
| + value = max;
|
| + return value;
|
| +}
|
| +
|
| +namespace gfx {
|
| +
|
| +Steps::Steps(int steps, bool steps_at_start)
|
| + : steps_(steps), steps_at_start_(steps_at_start) {
|
| +}
|
| +
|
| +Steps::~Steps() {
|
| +}
|
| +
|
| +double Steps::Solve(double x) const {
|
| + x = clamp(x, 0.0, 1.0);
|
| + return std::min(1.0, (floor(steps_ * x) + steps_at_start_) / steps_);
|
| +}
|
| +
|
| +void Steps::Range(double* min, double* max) const {
|
| + *min = static_cast<double>(steps_at_start_) / static_cast<double>(steps_);
|
| + *max = 1.0;
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|