xref: /aosp_15_r20/external/libchrome/ui/gfx/geometry/point_f.cc (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker 
5*635a8641SAndroid Build Coastguard Worker #include "ui/gfx/geometry/point_f.h"
6*635a8641SAndroid Build Coastguard Worker 
7*635a8641SAndroid Build Coastguard Worker #include "base/strings/stringprintf.h"
8*635a8641SAndroid Build Coastguard Worker 
9*635a8641SAndroid Build Coastguard Worker namespace gfx {
10*635a8641SAndroid Build Coastguard Worker 
SetToMin(const PointF & other)11*635a8641SAndroid Build Coastguard Worker void PointF::SetToMin(const PointF& other) {
12*635a8641SAndroid Build Coastguard Worker   x_ = x_ <= other.x_ ? x_ : other.x_;
13*635a8641SAndroid Build Coastguard Worker   y_ = y_ <= other.y_ ? y_ : other.y_;
14*635a8641SAndroid Build Coastguard Worker }
15*635a8641SAndroid Build Coastguard Worker 
SetToMax(const PointF & other)16*635a8641SAndroid Build Coastguard Worker void PointF::SetToMax(const PointF& other) {
17*635a8641SAndroid Build Coastguard Worker   x_ = x_ >= other.x_ ? x_ : other.x_;
18*635a8641SAndroid Build Coastguard Worker   y_ = y_ >= other.y_ ? y_ : other.y_;
19*635a8641SAndroid Build Coastguard Worker }
20*635a8641SAndroid Build Coastguard Worker 
ToString() const21*635a8641SAndroid Build Coastguard Worker std::string PointF::ToString() const {
22*635a8641SAndroid Build Coastguard Worker   return base::StringPrintf("%f,%f", x(), y());
23*635a8641SAndroid Build Coastguard Worker }
24*635a8641SAndroid Build Coastguard Worker 
ScalePoint(const PointF & p,float x_scale,float y_scale)25*635a8641SAndroid Build Coastguard Worker PointF ScalePoint(const PointF& p, float x_scale, float y_scale) {
26*635a8641SAndroid Build Coastguard Worker   PointF scaled_p(p);
27*635a8641SAndroid Build Coastguard Worker   scaled_p.Scale(x_scale, y_scale);
28*635a8641SAndroid Build Coastguard Worker   return scaled_p;
29*635a8641SAndroid Build Coastguard Worker }
30*635a8641SAndroid Build Coastguard Worker 
31*635a8641SAndroid Build Coastguard Worker 
32*635a8641SAndroid Build Coastguard Worker }  // namespace gfx
33