Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Defines a simple float vector class. This class is used to indicate a | |
| 6 // distance in two dimentions between two points. Subtracting two points should | |
| 7 // produce a vector, and adding a vector to a point produces the point at the | |
| 8 // vector's distance from the original point. | |
| 9 | |
| 10 #ifndef UI_GFX_VECTOR2D_F_H_ | |
| 11 #define UI_GFX_VECTOR2D_F_H_ | |
| 12 | |
| 13 #include <string> | |
| 14 | |
| 15 #include "ui/base/ui_export.h" | |
| 16 | |
| 17 namespace gfx { | |
| 18 | |
| 19 class UI_EXPORT Vector2dF { | |
| 20 public: | |
| 21 Vector2dF(); | |
| 22 Vector2dF(float x, float y); | |
| 23 | |
| 24 float x() const { return m_x; } | |
| 25 void set_x(float x) { m_x = x; } | |
| 26 | |
| 27 float y() const { return m_y; } | |
| 28 void set_y(float y) { m_y = y; } | |
| 29 | |
| 30 void Grow(float x, float y) { | |
| 31 m_x += x; | |
| 32 m_y += y; | |
| 33 } | |
| 34 | |
| 35 void Add(const Vector2dF& other) { | |
| 36 m_x += other.m_x; | |
| 37 m_y += other.m_y; | |
| 38 } | |
| 39 | |
| 40 std::string ToString() const; | |
| 41 | |
| 42 private: | |
| 43 float m_x; | |
|
tfarina
2012/10/25 00:40:20
nit: please remember that we are in chromium code,
| |
| 44 float m_y; | |
| 45 }; | |
| 46 | |
| 47 inline Vector2dF operator-(const Vector2dF& v) { | |
| 48 return Vector2dF(-v.x(), -v.y()); | |
| 49 } | |
| 50 | |
| 51 } // namespace gfx | |
| 52 | |
| 53 #endif // UI_GFX_VECTOR2D_F_H_ | |
| OLD | NEW |