Chromium Code Reviews| Index: ui/gfx/geometry/steps.cc |
| diff --git a/ui/gfx/geometry/steps.cc b/ui/gfx/geometry/steps.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d00dbd1b587afa5fd04262582420415a49099083 |
| --- /dev/null |
| +++ b/ui/gfx/geometry/steps.cc |
| @@ -0,0 +1,30 @@ |
| +// Copyright 2014 Samsung. All rights reserved. |
|
ajuma
2014/02/24 21:11:16
"The Chromium Authors"
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/gfx/geometry/steps.h" |
| + |
| +#include <cmath> |
| + |
| +#include "base/logging.h" |
| + |
| +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 { |
|
ajuma
2014/02/24 21:11:16
x should be clamped to [0, 1] (so that, e.g., Solv
|
| + return std::min(1.0, (floor(steps_ * x) + steps_at_start_) / steps_); |
| +} |
| + |
| +void Steps::Range(double* min, double* max) const { |
| + *min = static_cast<float>(steps_at_start_) / static_cast<float>(steps_); |
|
ajuma
2014/02/24 21:11:16
Use doubles instead of floats here (since *min is
|
| + *max = 1.0; |
| +} |
| + |
| +} // namespace gfx |