Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: ui/gfx/vector2d_f.h

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_
OLDNEW
« ui/gfx/vector2d.h ('K') | « ui/gfx/vector2d.cc ('k') | ui/gfx/vector2d_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698