Chromium Code Reviews| Index: ui/gfx/vector2d_f.h |
| diff --git a/ui/gfx/vector2d_f.h b/ui/gfx/vector2d_f.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2a451f9ff283e73df1e47889fa3d1927f61edd08 |
| --- /dev/null |
| +++ b/ui/gfx/vector2d_f.h |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2012 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. |
| + |
| +// Defines a simple float vector class. This class is used to indicate a |
| +// distance in two dimentions between two points. Subtracting two points should |
| +// produce a vector, and adding a vector to a point produces the point at the |
| +// vector's distance from the original point. |
| + |
| +#ifndef UI_GFX_VECTOR2D_F_H_ |
| +#define UI_GFX_VECTOR2D_F_H_ |
| + |
| +#include <string> |
| + |
| +#include "ui/base/ui_export.h" |
| + |
| +namespace gfx { |
| + |
| +class UI_EXPORT Vector2dF { |
| + public: |
| + Vector2dF(); |
| + Vector2dF(float x, float y); |
| + |
| + float x() const { return m_x; } |
| + void set_x(float x) { m_x = x; } |
| + |
| + float y() const { return m_y; } |
| + void set_y(float y) { m_y = y; } |
| + |
| + void Grow(float x, float y) { |
| + m_x += x; |
| + m_y += y; |
| + } |
| + |
| + void Add(const Vector2dF& other) { |
| + m_x += other.m_x; |
| + m_y += other.m_y; |
| + } |
| + |
| + std::string ToString() const; |
| + |
| + private: |
| + float m_x; |
|
tfarina
2012/10/25 00:40:20
nit: please remember that we are in chromium code,
|
| + float m_y; |
| +}; |
| + |
| +inline Vector2dF operator-(const Vector2dF& v) { |
| + return Vector2dF(-v.x(), -v.y()); |
| +} |
| + |
| +} // namespace gfx |
| + |
| +#endif // UI_GFX_VECTOR2D_F_H_ |