OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 Samsung. All rights reserved. | |
ajuma
2014/02/24 21:11:16
"The Chromium Authors"
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/gfx/geometry/steps.h" | |
6 | |
7 #include <cmath> | |
8 | |
9 #include "base/logging.h" | |
10 | |
11 namespace gfx { | |
12 | |
13 Steps::Steps(int steps, bool steps_at_start) | |
14 : steps_(steps), | |
15 steps_at_start_(steps_at_start) { | |
16 } | |
17 | |
18 Steps::~Steps() { | |
19 } | |
20 | |
21 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
| |
22 return std::min(1.0, (floor(steps_ * x) + steps_at_start_) / steps_); | |
23 } | |
24 | |
25 void Steps::Range(double* min, double* max) const { | |
26 *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
| |
27 *max = 1.0; | |
28 } | |
29 | |
30 } // namespace gfx | |
OLD | NEW |