blob: e8ecc805311091a258fd4aa454333ff3ad2a6a31 [file] [log] [blame]
// 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.
#include "cobalt/layout/vector2d_layout_unit.h"
#include <cmath>
#include "base/stringprintf.h"
namespace cobalt {
namespace layout {
std::string Vector2dLayoutUnit::ToString() const {
return base::StringPrintf("[%f %f]", x_.toFloat(), y_.toFloat());
}
bool Vector2dLayoutUnit::IsZero() const {
return x_ == LayoutUnit() && y_ == LayoutUnit();
}
void Vector2dLayoutUnit::Add(const Vector2dLayoutUnit& other) {
x_ += other.x_;
y_ += other.y_;
}
void Vector2dLayoutUnit::Subtract(const Vector2dLayoutUnit& other) {
x_ -= other.x_;
y_ -= other.y_;
}
} // namespace layout
} // namespace cobalt